473,326 Members | 2,076 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,326 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 2207
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.