Recently I had a problem with porting a Windows application to Linux because of the wchar_t
size difference between these platforms. I tried to use compiler switches, but there were problems with printing those characters (I presume that GCC wcout
thinks that all wchar_t
are 32bit).
So, my question: is there a nice way to (w)cout
char16_t
? I ask because it doesn't work, I'm forced to cast it to wchar_t
:
cout << (wchar_t) c;
It doesn't seem like a big problem, but it bugs me.
wchar_t
won't work. – Educatorwchar_t
and UTF-16 encoding. But that has nothing to do with size assumptions. 64bit systems have different sized types then 32bit systems, but that doesn't mean that your code will break on them. The lib you are mentioning works on Linux? – Educatorwchar_t
. Microsoft ignores the entire C part of the C++ standard and also redefines the meaning "string length" which means number ofwchar_t
not number of characters. This was already discussed many times here on stackoverflow. – Educator