UnicodeString
uses UTF-16 for storage by default. That's why it only has fromUTF8
and fromUTF32
: from UTF-16 there is no conversion to be made.
It does copy the data. It is an owning string, much like std::string
.
You can use UCharIterator
if you don't want to copy the data. UChar
is a 16-bit value. You can force it to be whatever 16-bit type you prefer working with by defining the UCHAR_TYPE
macro:
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is 16 bits wide; always assumed to be unsigned.
If neither is available, then define UChar to be uint16_t.
This makes the definition of UChar platform-dependent but allows direct string type compatibility with platforms with 16-bit wchar_t types.