473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

string problem

On my form i have a message box called txtItemDesc that displays the french
phrase qualité Père Noël. Now then when i run this code on that text box:

Dim chrArr() As Char
chrArr = txtItemDesc.Text.ToCharArray
Dim pos As Integer
While pos < chrArr.Length
Dim c As Char
MsgBox(Asc(chrArr(pos)) & " " & chrArr(pos))
pos = pos + 1
End While

I get this as my message box reply:
113 q (which is right in the ascii char set)
117 u
97 a
108 l
105 i
116 t
233 é (this is wrong in the extend ascii char set it should be 130)

How do i get this message box to print out the write ascii char value?

Nov 22 '05 #1
6 2215
john <jo**@discussions.microsoft.com> wrote:
On my form i have a message box called txtItemDesc that displays the french
phrase qualit? P?re No?l. Now then when i run this code on that text box:

Dim chrArr() As Char
chrArr = txtItemDesc.Text.ToCharArray
Dim pos As Integer
While pos < chrArr.Length
Dim c As Char
MsgBox(Asc(chrArr(pos)) & " " & chrArr(pos))
pos = pos + 1
End While

I get this as my message box reply:
113 q (which is right in the ascii char set)
117 u
97 a
108 l
105 i
116 t
233 ? (this is wrong in the extend ascii char set it should be 130)

How do i get this message box to print out the write ascii char value?


There's no single "extended ASCII" character set, and the plain ASCII
encoding only goes as far as 127.

You should use the *unicode* character you're interested in, and
preferrably avoid Asc which uses (IIRC) the default encoding for the
platform, which could be confusing things.

See http://www.pobox.com/~skeet/csharp/unicode.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
The problem i have is that i'm sending this data to a case labeling printer
that requires ascii. Now it does use the extended ascii set i know there are
multiples of them but the most common one of them is used. Here is a page
that has the extend chars that i need: http://www.lookuptables.com/
so is there a way to get those extended char values from the input string?

"Jon Skeet [C# MVP]" wrote:
john <jo**@discussions.microsoft.com> wrote:
On my form i have a message box called txtItemDesc that displays the french
phrase qualit? P?re No?l. Now then when i run this code on that text box:

Dim chrArr() As Char
chrArr = txtItemDesc.Text.ToCharArray
Dim pos As Integer
While pos < chrArr.Length
Dim c As Char
MsgBox(Asc(chrArr(pos)) & " " & chrArr(pos))
pos = pos + 1
End While

I get this as my message box reply:
113 q (which is right in the ascii char set)
117 u
97 a
108 l
105 i
116 t
233 ? (this is wrong in the extend ascii char set it should be 130)

How do i get this message box to print out the write ascii char value?


There's no single "extended ASCII" character set, and the plain ASCII
encoding only goes as far as 127.

You should use the *unicode* character you're interested in, and
preferrably avoid Asc which uses (IIRC) the default encoding for the
platform, which could be confusing things.

See http://www.pobox.com/~skeet/csharp/unicode.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #3
john <jo**@discussions.microsoft.com> wrote:
The problem i have is that i'm sending this data to a case labeling printer
that requires ascii.
No, it requires more than just ASCII by the sounds of it - as I said
before, actual ASCII only goes up as far as 127.
Now it does use the extended ascii set i know there are
multiples of them but the most common one of them is used. Here is a page
that has the extend chars that i need: http://www.lookuptables.com/
so is there a way to get those extended char values from the input string?


That's far from the most common these days (despite what the web page
says) - it's an encoding from the DOS days. I *suspect* it's code page
437, which you can get with Encoding.GetEncoding(437). It's worth
trying, certainly.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #4
thanks for the help Jon. You are right. it looks like the 437 char set is
the one I want. example of the set can be found at
http://www.georgehernandez.com/xComp...erSets/OEM.htm
I double check my label printers on my line i sent the ascii value of
char(130) and i recieved the results that i expected. now then i'm having a
problem with the conversion of the string still maybe you or someone can
point out where i'm going wrong. I'm still getting a code of 233 for char é
when it should be 130
'conversion code for my 437 encoding
' Create two different encodings.
Dim ibm437 As Encoding = Encoding.GetEncoding(437)
Dim [unicode] As Encoding = Encoding.Unicode

' Convert the string into a byte[].
Dim unicodeBytes As Byte() = [unicode].GetBytes(Me.TextBox1.Text)

' Perform the conversion from one encoding to the other.
Dim ibm437Bytes As Byte() = Encoding.Convert([unicode], ibm437,
unicodeBytes)

' Convert the new byte[] into a char[] and then into a string.
Dim imb437Chars(ibm437.GetCharCount(ibm437Bytes, 0,
ibm437Bytes.Length)) As Char
ibm437.GetChars(ibm437Bytes, 0, ibm437Bytes.Length, imb437Chars, 0)
Dim imb437String As New String(imb437Chars)

'checking my results from the conversion in a message box
Dim chrArr() As Char
chrArr = imb437String.ToCharArray

Dim pos As Integer
While pos < chrArr.Length
Dim c As Char
MsgBox(Asc(chrArr(pos)) & " " & chrArr(pos))
pos = pos + 1
End While

"Jon Skeet [C# MVP]" wrote:
john <jo**@discussions.microsoft.com> wrote:
The problem i have is that i'm sending this data to a case labeling printer
that requires ascii.


No, it requires more than just ASCII by the sounds of it - as I said
before, actual ASCII only goes up as far as 127.
Now it does use the extended ascii set i know there are
multiples of them but the most common one of them is used. Here is a page
that has the extend chars that i need: http://www.lookuptables.com/
so is there a way to get those extended char values from the input string?


That's far from the most common these days (despite what the web page
says) - it's an encoding from the DOS days. I *suspect* it's code page
437, which you can get with Encoding.GetEncoding(437). It's worth
trying, certainly.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #5
it seems to me by doing this it is converting it back into a uncode string
because i'm putting the Encoded 437 chars back into a windows char array.

right?
"john" wrote:
thanks for the help Jon. You are right. it looks like the 437 char set is
the one I want. example of the set can be found at
http://www.georgehernandez.com/xComp...erSets/OEM.htm
I double check my label printers on my line i sent the ascii value of
char(130) and i recieved the results that i expected. now then i'm having a
problem with the conversion of the string still maybe you or someone can
point out where i'm going wrong. I'm still getting a code of 233 for char é
when it should be 130
'conversion code for my 437 encoding
' Create two different encodings.
Dim ibm437 As Encoding = Encoding.GetEncoding(437)
Dim [unicode] As Encoding = Encoding.Unicode

' Convert the string into a byte[].
Dim unicodeBytes As Byte() = [unicode].GetBytes(Me.TextBox1.Text)

' Perform the conversion from one encoding to the other.
Dim ibm437Bytes As Byte() = Encoding.Convert([unicode], ibm437,
unicodeBytes)

' Convert the new byte[] into a char[] and then into a string.
Dim imb437Chars(ibm437.GetCharCount(ibm437Bytes, 0,
ibm437Bytes.Length)) As Char
ibm437.GetChars(ibm437Bytes, 0, ibm437Bytes.Length, imb437Chars, 0)
Dim imb437String As New String(imb437Chars)

'checking my results from the conversion in a message box
Dim chrArr() As Char
chrArr = imb437String.ToCharArray

Dim pos As Integer
While pos < chrArr.Length
Dim c As Char
MsgBox(Asc(chrArr(pos)) & " " & chrArr(pos))
pos = pos + 1
End While

"Jon Skeet [C# MVP]" wrote:
john <jo**@discussions.microsoft.com> wrote:
The problem i have is that i'm sending this data to a case labeling printer
that requires ascii.


No, it requires more than just ASCII by the sounds of it - as I said
before, actual ASCII only goes up as far as 127.
Now it does use the extended ascii set i know there are
multiples of them but the most common one of them is used. Here is a page
that has the extend chars that i need: http://www.lookuptables.com/
so is there a way to get those extended char values from the input string?


That's far from the most common these days (despite what the web page
says) - it's an encoding from the DOS days. I *suspect* it's code page
437, which you can get with Encoding.GetEncoding(437). It's worth
trying, certainly.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #6
nevermind thanks for the help i started to write my own converter for it.
it's working now.

"john" wrote:
it seems to me by doing this it is converting it back into a uncode string
because i'm putting the Encoded 437 chars back into a windows char array.

right?
"john" wrote:
thanks for the help Jon. You are right. it looks like the 437 char set is
the one I want. example of the set can be found at
http://www.georgehernandez.com/xComp...erSets/OEM.htm
I double check my label printers on my line i sent the ascii value of
char(130) and i recieved the results that i expected. now then i'm having a
problem with the conversion of the string still maybe you or someone can
point out where i'm going wrong. I'm still getting a code of 233 for char é
when it should be 130
'conversion code for my 437 encoding
' Create two different encodings.
Dim ibm437 As Encoding = Encoding.GetEncoding(437)
Dim [unicode] As Encoding = Encoding.Unicode

' Convert the string into a byte[].
Dim unicodeBytes As Byte() = [unicode].GetBytes(Me.TextBox1.Text)

' Perform the conversion from one encoding to the other.
Dim ibm437Bytes As Byte() = Encoding.Convert([unicode], ibm437,
unicodeBytes)

' Convert the new byte[] into a char[] and then into a string.
Dim imb437Chars(ibm437.GetCharCount(ibm437Bytes, 0,
ibm437Bytes.Length)) As Char
ibm437.GetChars(ibm437Bytes, 0, ibm437Bytes.Length, imb437Chars, 0)
Dim imb437String As New String(imb437Chars)

'checking my results from the conversion in a message box
Dim chrArr() As Char
chrArr = imb437String.ToCharArray

Dim pos As Integer
While pos < chrArr.Length
Dim c As Char
MsgBox(Asc(chrArr(pos)) & " " & chrArr(pos))
pos = pos + 1
End While

"Jon Skeet [C# MVP]" wrote:
john <jo**@discussions.microsoft.com> wrote:
> The problem i have is that i'm sending this data to a case labeling printer
> that requires ascii.

No, it requires more than just ASCII by the sounds of it - as I said
before, actual ASCII only goes up as far as 127.

> Now it does use the extended ascii set i know there are
> multiples of them but the most common one of them is used. Here is a page
> that has the extend chars that i need: http://www.lookuptables.com/
> so is there a way to get those extended char values from the input string?

That's far from the most common these days (despite what the web page
says) - it's an encoding from the DOS days. I *suspect* it's code page
437, which you can get with Encoding.GetEncoding(437). It's worth
trying, certainly.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
17
by: Olivier Bellemare | last post by:
I've tried to make a function that returns the middle of a string. For example: strmid("this is a text",6,4); would return "is a". Here is my code: char *strmid(char *texte, int depart,...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
4
by: MooMaster | last post by:
After some google searching on the forum I couldn't find any topics that seemed to relate exactly to my problem, so hopefully someone can help me out... I'm running python 2.4.1 on a local Win2K...
6
by: tommaso.gastaldi | last post by:
Hi, does anybody know a speedy analog of IsNumeric() to check for strings/chars. I would like to check if an Object can be treated as a string before using a Cstr(), clearly avoiding the time...
5
by: ThatVBGuy | last post by:
Hello All, I could really use some help with this problem its driving me nuts. I have a small vb app, the goal of the app is to read an html doc into a variable then go through that variable and...
1
Atli
by: Atli | last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling. The original Problem was posted as follows: As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.