2 **********************************************************************
3 * Copyright (c) 2001-2004, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 11/20/2001 aliu Creation.
8 **********************************************************************
13 #include "unicode/utypes.h"
15 #if !UCONFIG_NO_TRANSLITERATION
17 #include "unicode/translit.h"
22 * A transliterator that converts Unicode escape forms to the
23 * characters they represent. Escape forms have a prefix, a suffix, a
24 * radix, and minimum and maximum digit counts.
26 * <p>This class is package private. It registers several standard
27 * variants with the system which are then accessed via their IDs.
31 class U_I18N_API UnescapeTransliterator
: public Transliterator
{
36 * The encoded pattern specification. The pattern consists of
37 * zero or more forms. Each form consists of a prefix, suffix,
38 * radix, minimum digit count, and maximum digit count. These
39 * values are stored as a five character header. That is, their
40 * numeric values are cast to 16-bit characters and stored in the
41 * string. Following these five characters, the prefix
42 * characters, then suffix characters are stored. Each form thus
43 * takes n+5 characters, where n is the total length of the prefix
44 * and suffix. The end is marked by a header of length one
45 * consisting of the character END.
47 UChar
* spec
; // owned; may not be NULL
52 * Registers standard variants with the system. Called by
53 * Transliterator during initialization.
55 static void registerIDs();
58 * Constructor. Takes the encoded spec array (does not adopt it).
59 * @param ID the string identifier for this transliterator
60 * @param spec the encoded spec array
62 UnescapeTransliterator(const UnicodeString
& ID
,
68 UnescapeTransliterator(const UnescapeTransliterator
&);
73 virtual ~UnescapeTransliterator();
78 virtual Transliterator
* clone() const;
81 * ICU "poor man's RTTI", returns a UClassID for the actual class.
85 virtual UClassID
getDynamicClassID() const;
88 * ICU "poor man's RTTI", returns a UClassID for this class.
92 static UClassID U_EXPORT2
getStaticClassID();
97 * Implements {@link Transliterator#handleTransliterate}.
98 * @param text the buffer holding transliterated and
99 * untransliterated text
100 * @param offset the start and limit of the text, the position
101 * of the cursor, and the start and limit of transliteration.
102 * @param incremental if true, assume more text may be coming after
103 * pos.contextLimit. Otherwise, assume the text is complete.
105 void handleTransliterate(Replaceable
& text
, UTransPosition
& offset
,
106 UBool isIncremental
) const;
113 static Transliterator
* _createUnicode(const UnicodeString
& ID
, Token context
);
114 static Transliterator
* _createJava(const UnicodeString
& ID
, Token context
);
115 static Transliterator
* _createC(const UnicodeString
& ID
, Token context
);
116 static Transliterator
* _createXML(const UnicodeString
& ID
, Token context
);
117 static Transliterator
* _createXML10(const UnicodeString
& ID
, Token context
);
118 static Transliterator
* _createPerl(const UnicodeString
& ID
, Token context
);
119 static Transliterator
* _createAny(const UnicodeString
& ID
, Token context
);
121 static UChar
* copySpec(const UChar
* spec
);
127 #endif /* #if !UCONFIG_NO_TRANSLITERATION */