Garbled text in managed textbox on MFC native dialog (C++/CLI) -
09-13-2006
, 09:42 AM
I would appreciate help on the following problem:
I work on Visual Studio 2005 (.NET 2, MFC 8). My OS is Windows XP with
Hebrew MUI installed. OS UI language is English, default language
for-non Unicode programs is Hebrew (ANSI codepage 1255).
I've got solution containing two projects:
+ C++ MFC executable compiled with /clr switch and ANSI character set
+ C# control library
I've created MFC dialog and placed on it managed control from the C#
library, which contains textbox. In addition, I've created plain
textbox (CEdit) and placed it on the MFC dialog as well.
When I try to type Hebrew text into the managed textbox, it displays
characters from codepage 1252 (Wester Europe) instead of 1255 (Hebrew),
that is, the text appears garbled. However, when I set the content of
the managed textbox via code, Hebrew text is displayed properly. When I
type Hebrew text into the native textbox, it is displayed normally as
well.
I've checked the relevant properties of
System.Globalization.CultureInfo and they seem to be OK:
CurrentCulture has value {he-IL}
CurrentUICulture has value {en-US}
InstalledUICulture has value {en-US}
System.Globalization.CultureInfo.CurrentCulture.Te xtInfo.ANSICOdePage
is 1255
System.Globalization.CultureInfo.CurrentUICulture. TextInfo.ANSICOdePage
is 1252
When I change my OS UI language to Hebrew, CurrentUICulture becomes
{he-IL}, however, typed Hebrew text in managed textbox still appears
garbled.
When C++ project is compiled with Unicode character set, typed Hebrew
text in managed textbox is displayed properly and everything seems to
be OK.
I wonder if there is some way to correct this behavior via project
settings or code, other than switching the C++ project into Unicode (my
C++ project cannot be converted into Unicode at this moment). |