Share via


Displaying Hebrew text correctly in legacy applications on Windows 7

I recently helped a customer where a legacy application (test application written in Visual Basic 6 using a COM component written in Visual C++) was displaying Hebrew characters incorrectly in Windows 7 and Windows Server 2008 R2. The same application had worked fine on some Windows Server 2008 machines the customer had. However the code was relying on the correct locale settings and international settings being present in the user context of the thread in which the code was running.

It took a bit of experimentation but in the end it proved necessary to do the following:

Change the system locale:

clip_image002

clip_image002[4]

and also the international settings under Formats/Format:

clip_image002[6]

This allowed text to be converted and displayed correctly for an application running in the context of the user logged onto the desktop.

For code that was running as a Windows service running under the SYSTEM account it was also necessary to copy the international settings into the user context for the “welcome screen, system accounts and new user accounts”:

clip_image002[8]

clip_image002[10]

 

In .NET you can be a bit more explicit about how you convert an array of bytes in a specific code page. For example the following C# code will show the text correctly assuming the bytes supplied are the correct bytes from the 1255 code page:

 

unchecked
            {
                byte[] b = new byte[3] { (byte)xx, (byte)xx, (byte)xx};
                Encoding enc = Encoding.GetEncoding(1255); // Hebrew code page
                string s = enc.GetString(b, 0, 3);
                MessageBox.Show(s);
            }

HTH

Doug