tags:

views:

278

answers:

6

I have a C# form based program and have been using System.Text.Encoding.GetEncoding(1252) but I've had trouble reading non-English characters, I've discovered System.Text.Encoding.GetEncoding(1255) works however I don't know the implications of changing this so I'm hoping someone can shed some light on the difference and possible implications.

+4  A: 

I recommend that you read Joel Spolsky's article The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

klausbyskov
+1 Good link, thanks!
systempuntoout
+2  A: 

Character encoding 1255 includes Hebrew symbols whereas 1252 is geared towards Western Languages. Is it the case that the non-English symbols happen to be Hebrew?

Thomas
Correct, the characters are Hebrew
Jonathan
+1  A: 

1252 is Windows-1252 Western European (Windows)

1255 is Windows-1255 Hebrew (Windows)

source: http://msdn.microsoft.com/en-us/library/system.text.encodinginfo.codepage.aspx

Webleeuw
+1  A: 

When you use GetEncoding(1252), you're specifying the Windows-1252 Encoding, which specifies a latin alphabet for Western Europe. GetEncoding(1255) is the Windows-1255 encoding, which is used to write Hebrew.

Reed Copsey
+1  A: 

You probably want to use one of the "named" Unicode encodings, eg., Encoding.UTF8. But, to answer your question - page 1252 is "Western European (Windows)" and 1255 is "Hebrew (Windows)".

If you're not aware, code pages are pretty much a relic of ASCII and you should try to stick with Unicode where possible.

Mark Brackett
Hi Mark, When using UTF8 I can load the file but I see ��� instead of Hebrew characters. Should UTF8 work? Thanks
Jonathan
@Jonathan - Where is this data coming from? Is it being typed, or loaded from a file? Copied and pasted?
Mark Brackett
+1  A: 

Your encoding should always match the one that was used to create the file. If there is no metadata (or person) available to guide this selection, then the only thing to do would be to try each one and see which is legible. Since this is apparently in a language that you don't know, you may need to ask someone who speaks the language if it's legible. Do you know anyone who can read Hebrew?

Jeffrey L Whitledge