Vince
Vince

Reputation: 2646

Is it possible to use unicode characters in a Win32 resource file?

I have a Win32 program where the main window is a dialog box, so I can create all the controls using the resource.rc file. I'm stuck at creating a button using a unicode character though. It works with using the CreateWindowEx() function, but not in the resource file. Why is that?

I've tried the following lines of code in my resource file:

#include <wchar.h> // tried with and without this header file
// also tried defining UNICODE but i got an error saying it was already defined
CONTROL "\u2190", IDC_BACK //...more stuff
CONTROL L"\u2190", IDC_BACK //...more stuff

Upvotes: 4

Views: 2140

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 595339

To use non-ASCII characters in a resource, you can either save the .rc file in UTF-16 with a BOM, or else save the file in Ansi and use a #pragma codepage directive to indicate the file's codepage. I would suggest UTF-16. Either way, you can then use the actual character instead of using "\u":

CONTROL "←", IDC_BACK

Upvotes: 6

Related Questions