Converting from a Local Encoding to UTF-16
To provide a convenient method for translation between character encodings,
RWUString works directly with character-encoding converters in the Internationalization Module.
For example, if you want to write out to UTF-16 a string encoded in the Japanese Shift-JIS, you would use the following.
#include "rw/i18n/RWUToUnicodeConverter.h" // 1
RWCString myString;
// Initialize myString with characters encoded in Shift-JIS
RWUToUnicodeConverter fromShiftJis("Shift-JIS"); // 2
RWByteOutputStream& tmpBStream =
RWByteToStreambufOutputStreamImp::make(cout.rdbuf());
RWDataOutputStream tmpDStream =
RWNativeDataToByteOutputStreamImp::make(tmpBStream);
RWObjectOutputStream out =
RWCompactObjectOutputStreamImp::make(tmpDStream); // 3
out << RWUString(myString, fromShiftJis); // 4