I'm using the following to print a message in a Win32 API MessageBox:
MessageBox(hWnd, TEXT("Já existe um controlador em execução"), TEXT("Erro"), 0);
MessageBox is a macro and is expanding to MessageBoxW. The trouble is that it doesn't print Unicode, whereas the window that calls it prints Unicode without any issue, it seems that this is a problem with MessageBox itself.
Does anyone know how to solve this?
FYI, I also tried:
MessageBoxEx(hWnd, TEXT("Já existe um controlador em execução"), TEXT("Erro"), 0, MAKELANGID(LANG_PORTUGUESE, SUBLANG_PORTUGUESE));
But it's the same, as expected.
Here is a picture of the call with the expansion:

And it prints:

Note that the main window menu has unicode characters that are printed correctly.
To avoid source-code encoding based problems in the future, you can use \uxxxx style escape characters for non-ascii characters:
MessageBoxW(nullptr, L"J\u00E1 existe um controlador em execu\u00E7\u00E1o", L"Erro", MB_OK);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With