I'm writing strings to an embedded console that only supports Extended ASCII
Code Page 437.
The strings are stored in a lookup table in a database .
My original code is as follows which writes to a memory stream:
System.Text.ASCIIEncoding Encoding = new System.Text.ASCIIEncoding();
MachineIDs.Write(Encoding.GetBytes(EquipmentRecord.LabelID));
MachineIDs.Write('\0');
MachineIDs.Write(Encoding.GetBytes(EquipmentRecord.EnglishDesc));
MachineIDs.Write('\0');
MachineIDs.Write(Encoding.GetBytes(EquipmentRecord.GermanDesc));
MachineIDs.Write('\0');
The above code isn't writing using the correct code page.The german 'ü' char
0xFC is being written as char 0x3F using the above.
How do I specify a code page please?
thanks
Claire
Marc Gravell - 23 Oct 2007 12:02 GMT
Are you after 0x81?
Encoding enc = Encoding.GetEncoding(437);
char[] c = { (char)0xFC};
byte[] bytes = enc.GetBytes(c);
Marc
Marc Gravell - 23 Oct 2007 12:06 GMT
(for reference, I only used the char[] syntax to avoid the character
getting corrupted between your client and mine... strings should work
fine too)
Marc
Claire - 23 Oct 2007 12:11 GMT
thanks marc :-)
Marc Gravell - 23 Oct 2007 12:23 GMT
Jon Skeet [C# MVP] - 23 Oct 2007 12:23 GMT
> (for reference, I only used the char[] syntax to avoid the character
> getting corrupted between your client and mine... strings should work
> fine too)
One alternative:
string umlaut = "\u00fc";
Just to avoid the char[] stuff.
Jon
Marc Gravell - 23 Oct 2007 12:44 GMT