subirshan
subirshan

Reputation: 333

Converting text To Hebrew Characters c# winform Encoding

I have a string: ‰€‹†… ‰‰‰ ;

I want to display it in a textbox but with it's hebrew value .

I know for a fact that it is a hebrew string but something with the encoding set the result to the string you see.

How can I convert it in my Code so I can see it in hebrew.

I tried:

string a = " ‰€‹†… ‰‰‰ " ;
string b = " âìéåï " ; // this string works.
Encoding latinEncoding = Encoding.GetEncoding("Windows-1252");
Encoding hebrewEncoding = Encoding.GetEncoding("Windows-1255");
byte[] latinBytes = latinEncoding.GetBytes(a);
string hebrewString = hebrewEncoding.GetString(latinBytes);
textBox1.Text = hebrewString;

The thing is that if the string was b , it works. but all my strings are as a.

Upvotes: 1

Views: 6594

Answers (1)

argaz
argaz

Reputation: 1488

Your string is not encoded in windows-1255 encoding, it is encoded in code page 862, sometimes called MS-DOS Hebrew, so the code should be:

Encoding hebrewEncoding = Encoding.GetEncoding(862);

Upvotes: 3

Related Questions