Search code examples
c++unicode

Size of wchar_t for unicode encoding


is there 32-bit wide character for encoding UTF-32 strings? I'd like to do it via std::wstring which apparently showing me size of a wide character is 16 bits on windows platform.


Solution

  • You won't be able to do it with std::wstring on many platforms because it will have 16 bit elements.

    Instead you should use std::basic_string<char32_t>, but this requires a compiler with some C++0x support.