Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ASCII code problems
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00672238
Message ID:
00672245
Views:
10
I just ran this sample code and it returned 149. Try this and see what you get:
String cString;
Char mychar;
mychar=(char)149;
cString = mychar.ToString() + "ABC";
int lnChar = (int)Char.Parse(cString.Substring( 0, 1 ));
>I'm having a problem with some ascii codes here and I can't figure it out. It would be great if someone could help me. Anyway, in VFP:
>
>?chr( asc(chr(149))
>
>displays some weird symbol, but a symbol I need.
>
>the problem is with the chr(149). Of course, I'm not actually using
>'chr(149)', but the appropriate character. Just doing it this way for display purposes here.
>Now, if I had a string that began with chr(149), in c#:
>
>int nAscVal = (int)Char.Parse( cString.Substring( 0, 1 ) )
>
>
>nAscVal now has a value of 8226, it should be 149.
>
>It must have something to do with the encoding, but I don't know what. I've tried some stuff, like:
>
>int pintAsc = (new ASCIIEncoding()).GetBytes(new char[]{Char.Parse( cString.Substring( 0, 1 ))})[0];
>
>but no matter what character I select with the substring, it always returns a value of 63 to pintAsc. I'm lost on this one, anyone got any clues? Thanks,
>jfh
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform