Converting from UTF-16 to a Local Encoding
Similarly, if you want to read in a document containing a string encoded in UTF-16, and then convert the string to Shift-JIS, use the following code.
 
#include "rw/i18n/RWUFromUnicodeConverter.h"
RWUFromUnicodeConverter toShiftJis("Shift-JIS");
RWByteInputStream& tmpBStream =
RWByteFromStreambufInputStreamImp::make(cin.rdbuf());
RWDataInputStream tmpStream =
RWNativeDataFromByteInputStreamImp::make(tmpBStream);
RWObjectInputStream in =
RWCompactObjectInputStreamImp::make(tmpStream);
 
RWUString someRWUString;
in >> someRWUString;
someRWUString.toBytes(toShiftJis); // 1
//1 Use the toBytes() method of the RWUString to convert from UTF-16 to Shift-JIS.