Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Using code pages

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Claire - 23 Oct 2007 11:46 GMT
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
you are most welcome
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.