Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 650
Vince Avatar asked Oct 27 '25 01:10

Vince


1 Answers

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
like image 94
Remy Lebeau Avatar answered Oct 29 '25 16:10

Remy Lebeau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!