Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNo next file
Internationalization Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWUToUnicodeConverter

Module:  Internationalization Module   Group:  Character Encoding Scheme Conversion


RWUToUnicodeConverter RWUConverterBase

Local Index

Members

Header File

#include <rw/i18n/RWUToUnicodeConverter.h> 

Description

RWUToUnicodeConverter provides a unidirectional text conversion facility for translating from strings in various encodings to UTF-16 encoded RWUStrings.

A converter does not synchronize modifications to its internal state, so converters cannot be shared between threads.

The convert() method appends the results of a conversion to a target buffer. If its flush argument is true, convert() flushes its internal buffers to the target buffer and clears its internal state. For modal encodings such as ISO-2022, clearing the internal state ensures that the next call to convert() can expect the source text to begin in the source encoding's default, unshifted state.

Calling convert() once with a value of true for flush is useful when converting a piece of text in its entirety from a source encoding to UTF-16. In contrast, convert() may be used to fill a target buffer in a piecemeal fashion. Repeatedly calling convert() with a value of false for flush, then calling it once with a value of true, causes convert() to flush its buffers and clear its internal state only at the end of a multi-invocation conversion process.

At the conclusion of a successful call to convert() with flush set to true, the converter is reset automatically to a default, initial state, ready to start a new conversion process. Sometimes, however, it may be necessary to reset a converter explicitly using the reset() method:

Error Handling

Use setErrorResponse() to control how a converter handles ill-formed character encoding sequences in the source data. Take special care when processing multibyte encodings:

Example

Related Classes

RWUConverterBase, RWUToUnicodeConversionContext

Public Typedefs

typedef RWTFunctorR1<bool, char&> ConverterByteSource;
typedef RWTFunctorR1<bool, RWUChar32> DelimiterTest;

Public Enums

enum ErrorResponseType { Stop,
                         Skip,
                         Substitute,
                         Escape
};

Static Member Functions

static DelimiterTest
getWhitespaceDelimiterTest();
static DelimiterTest
getCodePointDelimiterTest(RWUChar32 delimiter);

Public Constructors

RWUToUnicodeConverter(const char* encoding);
RWUToUnicodeConverter(const RWUConverterBase& original);

Public Destructor

~RWUToUnicodeConverter();

Public Member Operators

RWUToUnicodeConverter&
operator=(const RWUConverterBase& rhs);

Public Member Functions

void
convert(char source, RWUString& target, bool flush = true);
void
convert(const char* source, RWUString& target,
        bool flush = true);
void
convert(const char source[], int32_t size, RWUString& target, 
        bool flush = true);
void
convert(const RWCString& source, RWUString& target,
        bool flush = true);
void
convert(const RW_SL_STD(string)& source, RWUString& target,
        bool flush = true);
bool
convert(ConverterByteSource source, RWUChar32& target,
        size_t& currentByteCount, bool flushAtEnd = true);
bool
convert(ConverterByteSource source,
        RWUString& target,
        size_t& currentByteCount,
        size_t maxNumCodePoints = 0, 
        DelimiterTest delimiterTest =
          RWUToUnicodeConverter::getWhitespaceDelimiterTest(),
        bool ignoreLeadingDelimiters = true,
        bool flushAtEnd = true);
void
reset();
void
restoreErrorResponseState(const ErrorResponseState& state);

NOTE -- The saved state from one converter may be used to set the state on another converter. However, this operation may not be safe in future versions of the Internationalization Module.
ErrorResponseState
saveErrorResponseState() const;

NOTE -- The saved state from one converter may be used to set the state on another converter. However, this operation may not be safe in future versions of the Internationalization Module.
void
setErrorResponse(ErrorResponseType response);

Class ErrorResponseState

RWUToUnicodeConverter::ErrorResponseState stores the current error response state of a converter so that it can be used to restore that state at a later time. See saveErrorResponseState() and restoreErrorResponseState().

Public Constructors

ErrorResponseState(const ErrorResponseState& state);

Public Member Operators

ErrorResponseState&
operator=(const ErrorResponseState& state);


Previous fileTop of DocumentContentsIndex pageNo next 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.