UnicodeString to char* (UTF-8)
call UnicodeString::extract(...)
to extract into a char*, pass NULL for the converter to get the default converter (which is in the charset which your OS will be using).
ICU User Guide > UTF-8 provides methods and descriptions of doing that.
The simplest way to use UTF-8 strings in UTF-16 APIs is via the C++
icu::UnicodeString
methodsfromUTF8(const StringPiece &utf8)
andtoUTF8String(StringClass &result)
. There is alsotoUTF8(ByteSink &sink)
.
And extract()
is not prefered now.
Note:
icu::UnicodeString
has constructors,setTo()
andextract()
methods which take either a converter object or a charset name. These can be used for UTF-8, but are not as efficient or convenient as thefromUTF8()
/toUTF8()
/toUTF8String()
methods mentioned above.