The rtl::OUString stores the text in UTF-16, however a lot of applications are handling UTF-8. The problem is to convert each OUString into the right encoding
First thing to do is to fully understand what we are doing: what are we converting ? is this really UTF-16 (UCS-2) ? The code shows how to create a correct string.
The important trick is to use the rtl::OUStringToOString() function with the RTL_TEXTENCODING_UTF8 flag. Have a look at the code: a piece of code if much better than a long text ;)