Question

I am building an MFC C++ application with "Use Unicode Character Set" selected in Visual Studio. I have UNICODE defined, my CStrings are 16-bit, I handle filenames with Japanese characters in them, etc. But, when I put Unicode strings containing Japanese characters in a CComboBox (using AddString), they show up as ?????.

I'm running Windows XP Professional x64 (in English). If I use Windows Control Panel Regional and Language Options, Advanced Tab, and set the Language for non-Unicode programs to Japanese, my combo box looks right.

So, I want my combo box to look right, and I want to understand why the "Language for non-Unicode programs" setting is changing the behavior of my Unicode program. Is there something else I should do to tell Windows my application is a Unicode application?

Thanks for any help!

Was it helpful?

Solution

Windows knows the difference between Unicode and non-Unicode programs by the functions they call. Most Windows API functions will come in two variants, one ending in A for non-Unicode and one ending in W for Unicode. The include files that define these functions will use the compiler settings to pick one or the other for you automatically.

The characters might not be coming out properly because you've selected a font that doesn't include them to be your default UI font.

OTHER TIPS

Where do you get the strings from? If they are hard-coded in your C sources, then at the time you call AddString they are (most likely) already damaged.

Nothing prevents one from taking some Unicode string, "squeeze" it in a std::string, for instance, and damage it. Even if the applications is compiled as Unicode.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top