intl/icu/source/i18n/esctrn.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/esctrn.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,142 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +*   Copyright (c) 2001-2007, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +**********************************************************************
     1.9 +*   Date        Name        Description
    1.10 +*   11/20/2001  aliu        Creation.
    1.11 +**********************************************************************
    1.12 +*/
    1.13 +#ifndef ESCTRN_H
    1.14 +#define ESCTRN_H
    1.15 +
    1.16 +#include "unicode/utypes.h"
    1.17 +
    1.18 +#if !UCONFIG_NO_TRANSLITERATION
    1.19 +
    1.20 +#include "unicode/translit.h"
    1.21 +
    1.22 +U_NAMESPACE_BEGIN
    1.23 +
    1.24 +/**
    1.25 + * A transliterator that converts Unicode characters to an escape
    1.26 + * form.  Examples of escape forms are "U+4E01" and "".
    1.27 + * Escape forms have a prefix and suffix, either of which may be
    1.28 + * empty, a radix, typically 16 or 10, a minimum digit count,
    1.29 + * typically 1, 4, or 8, and a boolean that specifies whether
    1.30 + * supplemental characters are handled as 32-bit code points or as two
    1.31 + * 16-bit code units.  Most escape forms handle 32-bit code points,
    1.32 + * but some, such as the Java form, intentionally break them into two
    1.33 + * surrogate pairs, for backward compatibility.
    1.34 + *
    1.35 + * <p>Some escape forms actually have two different patterns, one for
    1.36 + * BMP characters (0..FFFF) and one for supplements (>FFFF).  To
    1.37 + * handle this, a second EscapeTransliterator may be defined that
    1.38 + * specifies the pattern to be produced for supplementals.  An example
    1.39 + * of a form that requires this is the C form, which uses "\\uFFFF"
    1.40 + * for BMP characters and "\\U0010FFFF" for supplementals.
    1.41 + *
    1.42 + * <p>This class is package private.  It registers several standard
    1.43 + * variants with the system which are then accessed via their IDs.
    1.44 + *
    1.45 + * @author Alan Liu
    1.46 + */
    1.47 +class EscapeTransliterator : public Transliterator {
    1.48 +
    1.49 + private:
    1.50 +
    1.51 +    /**
    1.52 +     * The prefix of the escape form; may be empty, but usually isn't.
    1.53 +     */
    1.54 +    UnicodeString prefix;
    1.55 +
    1.56 +    /**
    1.57 +     * The prefix of the escape form; often empty.
    1.58 +     */
    1.59 +    UnicodeString suffix;
    1.60 +
    1.61 +    /**
    1.62 +     * The radix to display the number in.  Typically 16 or 10.  Must
    1.63 +     * be in the range 2 to 36.
    1.64 +     */
    1.65 +    int32_t radix;
    1.66 +
    1.67 +    /**
    1.68 +     * The minimum number of digits.  Typically 1, 4, or 8.  Values
    1.69 +     * less than 1 are equivalent to 1.
    1.70 +     */
    1.71 +    int32_t minDigits;
    1.72 +
    1.73 +    /**
    1.74 +     * If true, supplementals are handled as 32-bit code points.  If
    1.75 +     * false, they are handled as two 16-bit code units.
    1.76 +     */
    1.77 +    UBool grokSupplementals;
    1.78 +
    1.79 +    /**
    1.80 +     * The form to be used for supplementals.  If this is null then
    1.81 +     * the same form is used for BMP characters and supplementals.  If
    1.82 +     * this is not null and if grokSupplementals is true then the
    1.83 +     * prefix, suffix, radix, and minDigits of this object are used
    1.84 +     * for supplementals.  This pointer is owned.
    1.85 +     */
    1.86 +    EscapeTransliterator* supplementalHandler;
    1.87 +
    1.88 + public:
    1.89 +
    1.90 +    /**
    1.91 +     * Registers standard variants with the system.  Called by
    1.92 +     * Transliterator during initialization.
    1.93 +     */
    1.94 +    static void registerIDs();
    1.95 +
    1.96 +    /**
    1.97 +     * Constructs an escape transliterator with the given ID and
    1.98 +     * parameters.  See the class member documentation for details.
    1.99 +     */
   1.100 +    EscapeTransliterator(const UnicodeString& ID,
   1.101 +                         const UnicodeString& prefix, const UnicodeString& suffix,
   1.102 +                         int32_t radix, int32_t minDigits,
   1.103 +                         UBool grokSupplementals,
   1.104 +                         EscapeTransliterator* adoptedSupplementalHandler);
   1.105 +
   1.106 +    /**
   1.107 +     * Copy constructor.
   1.108 +     */
   1.109 +    EscapeTransliterator(const EscapeTransliterator&);
   1.110 +
   1.111 +    /**
   1.112 +     * Destructor.
   1.113 +     */
   1.114 +    virtual ~EscapeTransliterator();
   1.115 +
   1.116 +    /**
   1.117 +     * Transliterator API.
   1.118 +     */
   1.119 +    virtual Transliterator* clone() const;
   1.120 +
   1.121 +    /**
   1.122 +     * ICU "poor man's RTTI", returns a UClassID for the actual class.
   1.123 +     */
   1.124 +    virtual UClassID getDynamicClassID() const;
   1.125 +
   1.126 +    /**
   1.127 +     * ICU "poor man's RTTI", returns a UClassID for this class.
   1.128 +     */
   1.129 +    U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
   1.130 +
   1.131 + protected:
   1.132 +
   1.133 +    /**
   1.134 +     * Implements {@link Transliterator#handleTransliterate}.
   1.135 +     */
   1.136 +    virtual void handleTransliterate(Replaceable& text, UTransPosition& offset,
   1.137 +                             UBool isIncremental) const;
   1.138 +
   1.139 +};
   1.140 +
   1.141 +U_NAMESPACE_END
   1.142 +
   1.143 +#endif /* #if !UCONFIG_NO_TRANSLITERATION */
   1.144 +
   1.145 +#endif

mercurial