mercredi 19 mai 2010

ICU UnicodeString to UTF-8

Hello,

This morning, I spent most of the time to know how to convert an ICU UnicodeString to an UTF-8 string.

the result is so simple, but no documentation, nowhere on google land...
The ICU documentation is obviously not so up-to-date.
I am using the latest version of ICU thought (4.2).

so to convert UnicodeString to std::string is simple as:
UnicodeString us = ...;
string cs;
us.toUTF8String(cs);

so simple but so complex to find, I ended up to look at the source code...

so I hope it will be helpful for others....


6 commentaires: