Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
XML Streams Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

7.3 Using the XML Streams Package without the Internationalization Module

The XML Streams classes all use UTF-8 as their internal character encoding. If you need to use the encoding UTF-16, you may use the wide character interface RWWString, or the Unicode interface RWBasicUString. (If you need to convert your streams to and from other character encodings, you will need to build and link the Internationalization Module. For more information, see Section 7.4.)

7.3.1 Choosing the Appropriate String Class Interface

The Essential Tools Module provides string classes that allow you to build your XML streams in UTF-8 and UTF-16. (For more detailed information on the encodings supported by the Essential Tools Module, see Section 7.2.1.1.)

These classes are RWCString, RWWString, and RWBasicUString.


NOTE -- Using RWBasicUString for your UTF-16 strings is the recommended method over a conventional wide-character interface.

7.3.2 Converting to and from UTF-8 and UTF-16

You may convert your RWCStrings, RWBasicUStrings, and RWWStrings to and from UTF-8 and UTF-16 as needed.

7.3.2.1 Converting RWCStrings and RWBasicUStrings

RWBasicUString provides conversion to and from UTF-16 and an RWCString containing UTF-8.

7.3.2.2 Converting RWWStrings to and from UTF-8

RWBasicUString does not provide a complete RWWString or wchar_t interface. (Its method towide() converts from UTF-16 to an RWWString, but it does not take a wchar_t and return a Unicode UTF-16 string.)

To perform these wide character conversions, you may use the UTF-8 converter classes provided in the Advanced Tools Module's Stream package.

//1Start with an empty RWWString and an RWCString containing UTF-8 encoded characters.
//2Create the RWFromUTF8Converter.
//3Call 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 a UTF-16 RWWString.
//1Create a new empty RWCString and a new RWWString source.
//2Create the RWToUTF8Converter.
//3Call the convert() function on RWFromUTF8Converter with the source and destination strings as parameters. After this call, the newDestination local variable will contain the source string encoded in UTF-8.

NOTE -- Note that these wide character conversions are suitable only on systems where wchar_t's native encoding is UTF-16.


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.