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

8.3 International Features of the Streams Package

This section discusses using the Streams package with and without the Internationalization Module. To determine if you need to use the Internationalization Module, see Section 8.2, "Determining your Character Encoding Needs."

8.3.1 Using the Streams Package without the Internationalization Module

The Streams package provides a number of Unicode-based streams that allow you to stream data in a Unicode format. See Advanced Tools Module | Streams on the Modules tab of the SourcePro C++ API Reference Guide for specific APIs.

8.3.1.1 Unicode-Based Stream Classes

8.3.1.2 Unicode Converter Classes

RWToUTF8Converter and RWFromUTF8Converter provide character encoding conversions between UTF-8 and UTF-16. These classes use the same interface as the converters in the Internationalization Module, but do not require that module.


To perform conversions to or from character encodings other than UTF-8 and UTF-16, you will need the Internationalization Module.

These classes also provide interfaces for the RWUChar type and for wchar_t. (RWUChar is a typedef for unsigned short and is used by the Streams package to represent UTF-16 characters.) If you are using these types, use these classes for your conversions between UTF-8 and UTF-16.

However, if you are performing conversions that do not require the RWUChar or wchar_t interface, we recommend that you use instead RWBasicUString and its conversion utilities. For more information, see Section 8.2.4, "Choosing the Appropriate String Class."

8.3.1.3 Example

The following examples illustrate how to perform conversions using RWFromUTF8Converter and RWToUTF8Converter.

//1

Start with an empty RWWString and an RWCString containing UTF-8 encoded characters.

//2

Create the RWFromUTF8Converter converter 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.

//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.

8.3.2 Using the Streams Package with the Internationalization Module

If you wish to convert a string that will be inserted into a stream to a character encoding other than US-ASCII, UTF-8 or UTF-16, you will require the Internationalization Module.

The Internationalization Module converts to and from any supported character encoding to UTF-16. This conversion allows you to write applications in character encodings that require a wide character format (16-bits or greater), such as some Chinese and Japanese character encodings.

In some cases, you will be required to convert these UTF-16 strings and to UTF-8 for use in other SourcePro modules. See the relevant User's Guide for each module's requirements.

For more information on the supported character encodings, or other information on internationalization and localization of your applications, see the Internationalization Module User's Guide.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.