Even if std::wstring
is supported by other platforms, its definitions and meanings seem different from platform to platform: e.g. wchar_t
(which is the basic "building block" for a std::wstring
) is 2 bytes in size on Windows, while on on Linux it's 4 bytes.
So, you can use std::wstring
to store Unicode strings in UTF-16 format on Windows (which is also the Unicode format used by Win32 APIs), but on Linux your std::wstring
should be used to store Unicode UTF-32 strings. So, if the same class (std::wstring
) has different meanings on different platforms, I would not define that as portable.
Probably, if you want to write portable code, you could consider using std::string
and store Unicode UTF-8 text in it (in fact, std::string
is based on char
, which is 1 byte on both Windows and Linux).
Or, if you can use the new C++11 standard, you may want to consider std::u16string
, which is really portable, since it's defined as basic_string<char16_t>
, so it can be used to store Unicode UTF-16 text on every platform, without ambiguity.