Re: loadstring fails in MBCS encoding



Did you try to force the locale (language) with setlocale ?

setlocale( LC_ALL, "china");

char *setlocale(
int category,
const char *locale
);



"news" <nospam-se@xxxxxxxxx> wrote in message
news:dkt5u8$ef3$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> Implementation of CString::LoadString has changed from VC6 to VC7 and I
> can't load MBCS resources correctly any more.
> When I translate the application to Russian or Chinese languages, dialogs
> and menus and all strings defined directly in the resource file are well
> displayed but
> the problem is when I have to load dynamicaly some resources like this :
>
> CString s;
> s.LoadString (MY_ID_RESOURCE);
> m_edit.SetWindowText(s);
>
> Then, the string will be "????????" instead of the rigth one.
>
> Debugging, I have found that in VC7 LoadString implementation makes a
> conversion with a call to ConvertToBaseType method.
>
> I have found two solutions :
>
> the first one is to use TCHAR instead of CString :
>
> TCHAR buf[255];
> LoadString(NULL, MY_ID_RESOURCE, buf, 255);
> m_edit.SetWindowText(buf);
>
> the second one is to change properties of the project by changing
> Character Set from MBCS to Unicode.
>
> Unfortunatly, neither of the two solutions are possible.
>
> The first one cannot be used because there are also dynamic loads in mfc
> code (like for the title of the main frame).
>
> The second one makes two much changes in the code of the application which
> is two large.
>
> Does any body has an idea ?
> Thanks in advance.
> Selena
>
>
>
>
>
>


.