michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (c) 2001-2007, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * Date Name Description michael@0: * 11/20/2001 aliu Creation. michael@0: ********************************************************************** michael@0: */ michael@0: #ifndef ESCTRN_H michael@0: #define ESCTRN_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_TRANSLITERATION michael@0: michael@0: #include "unicode/translit.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /** michael@0: * A transliterator that converts Unicode characters to an escape michael@0: * form. Examples of escape forms are "U+4E01" and "". michael@0: * Escape forms have a prefix and suffix, either of which may be michael@0: * empty, a radix, typically 16 or 10, a minimum digit count, michael@0: * typically 1, 4, or 8, and a boolean that specifies whether michael@0: * supplemental characters are handled as 32-bit code points or as two michael@0: * 16-bit code units. Most escape forms handle 32-bit code points, michael@0: * but some, such as the Java form, intentionally break them into two michael@0: * surrogate pairs, for backward compatibility. michael@0: * michael@0: *
Some escape forms actually have two different patterns, one for michael@0: * BMP characters (0..FFFF) and one for supplements (>FFFF). To michael@0: * handle this, a second EscapeTransliterator may be defined that michael@0: * specifies the pattern to be produced for supplementals. An example michael@0: * of a form that requires this is the C form, which uses "\\uFFFF" michael@0: * for BMP characters and "\\U0010FFFF" for supplementals. michael@0: * michael@0: *
This class is package private. It registers several standard michael@0: * variants with the system which are then accessed via their IDs. michael@0: * michael@0: * @author Alan Liu michael@0: */ michael@0: class EscapeTransliterator : public Transliterator { michael@0: michael@0: private: michael@0: michael@0: /** michael@0: * The prefix of the escape form; may be empty, but usually isn't. michael@0: */ michael@0: UnicodeString prefix; michael@0: michael@0: /** michael@0: * The prefix of the escape form; often empty. michael@0: */ michael@0: UnicodeString suffix; michael@0: michael@0: /** michael@0: * The radix to display the number in. Typically 16 or 10. Must michael@0: * be in the range 2 to 36. michael@0: */ michael@0: int32_t radix; michael@0: michael@0: /** michael@0: * The minimum number of digits. Typically 1, 4, or 8. Values michael@0: * less than 1 are equivalent to 1. michael@0: */ michael@0: int32_t minDigits; michael@0: michael@0: /** michael@0: * If true, supplementals are handled as 32-bit code points. If michael@0: * false, they are handled as two 16-bit code units. michael@0: */ michael@0: UBool grokSupplementals; michael@0: michael@0: /** michael@0: * The form to be used for supplementals. If this is null then michael@0: * the same form is used for BMP characters and supplementals. If michael@0: * this is not null and if grokSupplementals is true then the michael@0: * prefix, suffix, radix, and minDigits of this object are used michael@0: * for supplementals. This pointer is owned. michael@0: */ michael@0: EscapeTransliterator* supplementalHandler; michael@0: michael@0: public: michael@0: michael@0: /** michael@0: * Registers standard variants with the system. Called by michael@0: * Transliterator during initialization. michael@0: */ michael@0: static void registerIDs(); michael@0: michael@0: /** michael@0: * Constructs an escape transliterator with the given ID and michael@0: * parameters. See the class member documentation for details. michael@0: */ michael@0: EscapeTransliterator(const UnicodeString& ID, michael@0: const UnicodeString& prefix, const UnicodeString& suffix, michael@0: int32_t radix, int32_t minDigits, michael@0: UBool grokSupplementals, michael@0: EscapeTransliterator* adoptedSupplementalHandler); michael@0: michael@0: /** michael@0: * Copy constructor. michael@0: */ michael@0: EscapeTransliterator(const EscapeTransliterator&); michael@0: michael@0: /** michael@0: * Destructor. michael@0: */ michael@0: virtual ~EscapeTransliterator(); michael@0: michael@0: /** michael@0: * Transliterator API. michael@0: */ michael@0: virtual Transliterator* clone() const; michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for the actual class. michael@0: */ michael@0: virtual UClassID getDynamicClassID() const; michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for this class. michael@0: */ michael@0: U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); michael@0: michael@0: protected: michael@0: michael@0: /** michael@0: * Implements {@link Transliterator#handleTransliterate}. michael@0: */ michael@0: virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, michael@0: UBool isIncremental) const; michael@0: michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_TRANSLITERATION */ michael@0: michael@0: #endif