1

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.

4
  • You can change display font of local language. It work fine Commented Jun 8, 2013 at 16:06
  • Are you sure " ‰€‹†… ‰‰‰ " is latin encoding? Commented Jun 8, 2013 at 16:10
  • No King. If I open the file with notepad , I get string a . If I open the file with ultraedit , I get stirng b . When i read the content of the file with my code , I get string a. And therefor my convertion don't work . Commented Jun 8, 2013 at 16:17
  • @subirshan if so your problem is to detect the right source encoding. I think you should try this File.ReadAllText(filePath,hebrewEncoding);, your ultraedit may open the file with right encoding, if the code I suggested doesn't work, you can try with latinEncoding first, then convert to hebrewEncoding text like as you do in your code. Commented Jun 8, 2013 at 16:59

1 Answer 1

3

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); 
Sign up to request clarification or add additional context in comments.

2 Comments

thanks . It display the hebrew value but with the letters in opposite direction. I mean from end to begining . Any ideas Why ?
It seems that the original string is in visual order, rather than in logical, probably coming from an older system. Because windows knows that hebrew should be rendered RTL, it gets flipped again. If your input will always be a simple hebrew string you can flip it, otherwise you probably need to use an implementation of the algorithm used to convert logical to visual text (called BiDi). Because this conversion is a many to one function, the reverse conversion may not be correct, but the same algorithm will reverse correctly simple input. For .NET The only 3rd party I've found is: nbidi.sf.net

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.