Let's say we have file main.cpp in windows-1251 encoding with such content:
int main()
{
wchar_t* ws = L"котэ"; //cat in russian
return 0;
}
Everything is fine if we compile this in VisualStudio, BUT we gonna compile it with GCC which default encoding for source code is UTF-8. Of course we can convert file encoding or set option "-finput-charset=windows-1251" for compiler, but what if not? There is some way to do this by replacing raw text into hex UTF32 bytes:
int main()
{
wchar_t* ws = (wchar_t*)"\x3A\x04\x00\x00\x3E\x04\x00\x00\x42\x04\x00\x00\x4D\x04\x00\x00\x00\x00\x00\x00"; //cat in russian
return 0;
}
But it's kind of agly: 4 letters becomes a 20 bytes ((
How else it can be done?