My program need to display some unicode strings. If I save the source code using UTF-16LE, everything works fine. However, I was not be able to cross compile in linux using mingw. If I save the source using UTF-8, the source code can be compiled with no problem. But all the const unicode strings were not displayed correctly since they are encoded as UTF-8. How can I properly display unicode string when the source code is saved as UTF-8 encoded?
Example Code:
#include <Windows.h>
int main(int argc, const char *argv[])
{
MessageBoxW(NULL, L"你好", L"你好", MB_OK);
}
After some testing, it turns out visual studio cannot encode string correctly if the file is encoded to UTF-8 without signature(BOM). Everything works fine after changing encoding scheme to UTF-8 with signature.