Example
The following examples illustrate how to perform conversions using RWFromUTF8Converter and RWToUTF8Converter.
*Converting from UTF-8 to UTF-16
RWWString destination; // 1
RWCString source(“My UTF8 characters”);
 
RWFromUTF8Converter converter; // 2
converter.convert(source,destination); // 3
 
//1 Start with an empty RWWString and an RWCString containing UTF-8 encoded characters.
//2 Create the RWFromUTF8Converterconverter object.
//3 Call the convert() function on RWFromUTF8Converter with the source and destination strings as parameters. After this call, the destination local variable will contain the source string encoded in UTF-16.
*Converting from UTF-16 to UTF-8
RWWString newSource(destination);
RWCString newDestination; // 1
 
RWToUTF8Converter converter; // 2
converter.convert(newSource,newDestination); // 3
//1 Create a new empty RWCString newDestination and a new RWWString source initialized with the result of the previous conversion.
//2 Create the RWToUTF8Converter object.
//3 Call the convert() function on RWToUTF8Converter with the newSource and newDdestination strings as parameters. After this call, the newDestination local variable will contain an exact replica of the source string re-encoded in UTF-8.