Extended Ascii Encoding
-
Hi I want to convert the unicode string ( in DotNet) to extended ascii bytes. I tried UTF8Encoding and ASCIIEncoding. But in UTF8Encoding i am two bytes for the £ ( character value 163) In ACSIIEncoding I am getting question mark (?). How can I convert the character £ to a ascii byte value Please Help Regards
-
Hi I want to convert the unicode string ( in DotNet) to extended ascii bytes. I tried UTF8Encoding and ASCIIEncoding. But in UTF8Encoding i am two bytes for the £ ( character value 163) In ACSIIEncoding I am getting question mark (?). How can I convert the character £ to a ascii byte value Please Help Regards
You have to specify a codepage. Any characters about 127 in ASCII (since ASCII defines 7-bit characters, not 8-bit) depend upon a codepage for what those characters represent
byte[] ubuf = Encoding.Unicode.GetBytes(
"This is a string stored as Unicode in .NET.");
// Create an encoding for Windows-1252 codepage.
Encoding enc = Encoding.GetEncoding(1252);
byte[] abuff = Encoding.Convert(Encoding.Unicode, enc, ubuf);Microsoft MVP, Visual C# My Articles
-
You have to specify a codepage. Any characters about 127 in ASCII (since ASCII defines 7-bit characters, not 8-bit) depend upon a codepage for what those characters represent
byte[] ubuf = Encoding.Unicode.GetBytes(
"This is a string stored as Unicode in .NET.");
// Create an encoding for Windows-1252 codepage.
Encoding enc = Encoding.GetEncoding(1252);
byte[] abuff = Encoding.Convert(Encoding.Unicode, enc, ubuf);Microsoft MVP, Visual C# My Articles
-
Hi Thanks for your time. In the above example will I get a extened ascii bytes at abuff ? Regards Shiraz
Yes. As I said before, ASCII uses only 7-bit characters, so you only get characters below 128. You have to specify a codepage to get valid characters over that. Different regions use different codepages. The Greeks filled their last 128 characters with greek symbols, for example; the Russians with Cyrillic; so on, so forth. That link I provided will explain more.
Microsoft MVP, Visual C# My Articles
-
You have to specify a codepage. Any characters about 127 in ASCII (since ASCII defines 7-bit characters, not 8-bit) depend upon a codepage for what those characters represent
byte[] ubuf = Encoding.Unicode.GetBytes(
"This is a string stored as Unicode in .NET.");
// Create an encoding for Windows-1252 codepage.
Encoding enc = Encoding.GetEncoding(1252);
byte[] abuff = Encoding.Convert(Encoding.Unicode, enc, ubuf);Microsoft MVP, Visual C# My Articles
Hi there: This code helped me much, but I exatcly need its opposite. How can I change the Unicode numbers to characters?! Tnx in Advance. Always:), Hovik Melkomian.
-
Hi there: This code helped me much, but I exatcly need its opposite. How can I change the Unicode numbers to characters?! Tnx in Advance. Always:), Hovik Melkomian.
char c = (int)65;
c
is now "A".Microsoft MVP, Visual C# My Articles
-
Yes. As I said before, ASCII uses only 7-bit characters, so you only get characters below 128. You have to specify a codepage to get valid characters over that. Different regions use different codepages. The Greeks filled their last 128 characters with greek symbols, for example; the Russians with Cyrillic; so on, so forth. That link I provided will explain more.
Microsoft MVP, Visual C# My Articles