473,848 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Tex t.ToCharArray
Dim pos As Integer
While pos < chrArr.Length
Dim c As Char
MsgBox(Asc(chrA rr(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 2241
john <jo**@discussio ns.microsoft.co m> 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.Tex t.ToCharArray
Dim pos As Integer
While pos < chrArr.Length
Dim c As Char
MsgBox(Asc(chrA rr(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.co m>
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**@discussio ns.microsoft.co m> 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.Tex t.ToCharArray
Dim pos As Integer
While pos < chrArr.Length
Dim c As Char
MsgBox(Asc(chrA rr(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.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #3
john <jo**@discussio ns.microsoft.co m> 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.GetEnc oding(437). It's worth
trying, certainly.

--
Jon Skeet - <sk***@pobox.co m>
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.GetEnc oding(437)
Dim [unicode] As Encoding = Encoding.Unicod e

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

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

' Convert the new byte[] into a char[] and then into a string.
Dim imb437Chars(ibm 437.GetCharCoun t(ibm437Bytes, 0,
ibm437Bytes.Len gth)) As Char
ibm437.GetChars (ibm437Bytes, 0, ibm437Bytes.Len gth, imb437Chars, 0)
Dim imb437String As New String(imb437Ch ars)

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

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

"Jon Skeet [C# MVP]" wrote:
john <jo**@discussio ns.microsoft.co m> 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.GetEnc oding(437). It's worth
trying, certainly.

--
Jon Skeet - <sk***@pobox.co m>
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.GetEnc oding(437)
Dim [unicode] As Encoding = Encoding.Unicod e

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

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

' Convert the new byte[] into a char[] and then into a string.
Dim imb437Chars(ibm 437.GetCharCoun t(ibm437Bytes, 0,
ibm437Bytes.Len gth)) As Char
ibm437.GetChars (ibm437Bytes, 0, ibm437Bytes.Len gth, imb437Chars, 0)
Dim imb437String As New String(imb437Ch ars)

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

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

"Jon Skeet [C# MVP]" wrote:
john <jo**@discussio ns.microsoft.co m> 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.GetEnc oding(437). It's worth
trying, certainly.

--
Jon Skeet - <sk***@pobox.co m>
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.GetEnc oding(437)
Dim [unicode] As Encoding = Encoding.Unicod e

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

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

' Convert the new byte[] into a char[] and then into a string.
Dim imb437Chars(ibm 437.GetCharCoun t(ibm437Bytes, 0,
ibm437Bytes.Len gth)) As Char
ibm437.GetChars (ibm437Bytes, 0, ibm437Bytes.Len gth, imb437Chars, 0)
Dim imb437String As New String(imb437Ch ars)

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

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

"Jon Skeet [C# MVP]" wrote:
john <jo**@discussio ns.microsoft.co m> 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.GetEnc oding(437). It's worth
trying, certainly.

--
Jon Skeet - <sk***@pobox.co m>
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
10633
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 namespace std; : : vector<string>* getTyphoon()
17
14378
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, int longueur) { char *resultat = " "; char *temporaire = " "; int nbr;
51
8312
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 code? many thx!
18
7205
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 QID=\"55111\"><Tag2 AID=\"5511101\"></Tag2></Tag1><Tag1 QID=\"55112\"><Tag2 AID=\"5511217\"></Tag2></Tag1><Tag1 QID=\"5512282\"><Tag2 AID=\"551228206\"></Tag2></Tag1><Tag1 QID=\"55114\"><Tag2 AID=\"5511406\"></Tag2></Tag1><Tag1 QID=\"55115\"><Tag2
32
14936
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 ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
12
9654
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(" & Chr(34) & PopUpWindowTitle & Chr(34) & ", " & Chr(34) & CurrentEventDetails & ")" strTemp += "<BR><A HREF='#' onClick='" & PopupLink & "'>" & EventName & "</A><BR>" The problem I have is that when the string variables or contain a string with an...
4
5284
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 system and doing some work-related development on an AIX box, and I'm running into a problem using cx_Oracle to add some information to an Oracle 9.2 table. I have a table_title defined as a VARCHAR2 data type, and when I'm trying to retrieve...
6
2221
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 and resource consuming Try... Catch, which in iterative processing is totally unacceptable. -tom
5
3543
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 find and replace some tags. I have 3 functions. 1 to open the doc, the 2nd to find and replace the tags the 3rd to save the info. the code is pasted below : Public Function ReadFileContents(FileFullPath As String) As _ String On Error GoTo...
1
8381
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 you can see, there could have been a problem with the split-method. The following short article handles ways around this possible problem, that we couldn't reproduce, but someone may possibly encounter it too sometimes. If nothing else, the shown...
0
9893
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9738
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10664
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10348
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7894
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5735
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5919
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.