2 *******************************************************************************
4 * Copyright (C) 2003-2006, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 * tab size: 8 (not used)
13 * created on: 2003feb1
14 * created by: Ram Viswanadha
20 #include "unicode/utypes.h"
23 #if !UCONFIG_NO_TRANSLITERATION
25 #include "unicode/uniset.h"
26 #include "unicode/ures.h"
27 #include "unicode/translit.h"
32 #define ASCII_SPACE 0x0020
34 class NamePrepTransform
{
37 Transliterator
*mapping
;
38 UnicodeSet unassigned
;
39 UnicodeSet prohibited
;
40 UnicodeSet labelSeparatorSet
;
41 UResourceBundle
*bundle
;
42 NamePrepTransform(UParseError
& parseError
, UErrorCode
& status
);
47 static NamePrepTransform
* createInstance(UParseError
& parseError
, UErrorCode
& status
);
49 virtual ~NamePrepTransform();
52 inline UBool
isProhibited(UChar32 ch
);
55 * ICU "poor man's RTTI", returns a UClassID for the actual class.
59 inline UClassID
getDynamicClassID() const { return getStaticClassID(); }
62 * ICU "poor man's RTTI", returns a UClassID for this class.
66 static inline UClassID
getStaticClassID() { return (UClassID
)&fgClassID
; }
69 * Map every character in input stream with mapping character
70 * in the mapping table and populate the output stream.
71 * For any individual character the mapping table may specify
72 * that that a character be mapped to nothing, mapped to one
73 * other character or to a string of other characters.
75 * @param src Pointer to UChar buffer containing a single label
76 * @param srcLength Number of characters in the source label
77 * @param dest Pointer to the destination buffer to receive the output
78 * @param destCapacity The capacity of destination array
79 * @param allowUnassigned Unassigned values can be converted to ASCII for query operations
80 * If TRUE unassigned values are treated as normal Unicode code point.
81 * If FALSE the operation fails with U_UNASSIGNED_CODE_POINT_FOUND error code.
82 * @param status ICU error code in/out parameter.
83 * Must fulfill U_SUCCESS before the function call.
84 * @return The number of UChars in the destination buffer
87 int32_t map(const UChar
* src
, int32_t srcLength
,
88 UChar
* dest
, int32_t destCapacity
,
89 UBool allowUnassigned
,
90 UParseError
* parseError
,
94 * Prepare the input stream with for use. This operation maps, normalizes(NFKC),
95 * checks for prohited and BiDi characters in the order defined by RFC 3454
97 * @param src Pointer to UChar buffer containing a single label
98 * @param srcLength Number of characters in the source label
99 * @param dest Pointer to the destination buffer to receive the output
100 * @param destCapacity The capacity of destination array
101 * @param allowUnassigned Unassigned values can be converted to ASCII for query operations
102 * If TRUE unassigned values are treated as normal Unicode code point.
103 * If FALSE the operation fails with U_UNASSIGNED_CODE_POINT error code.
104 * @param status ICU error code in/out parameter.
105 * Must fulfill U_SUCCESS before the function call.
106 * @return The number of UChars in the destination buffer
108 int32_t process(const UChar
* src
, int32_t srcLength
,
109 UChar
* dest
, int32_t destCapacity
,
110 UBool allowUnassigned
,
111 UParseError
* parseError
,
112 UErrorCode
& status
);
115 * Ascertain if the given code point is a label separator as specified by IDNA
117 * @return TRUE is the code point is a label separator
121 UBool
isLabelSeparator(UChar32 ch
, UErrorCode
& status
);
124 inline UBool
isLDHChar(UChar32 ch
);
127 * The address of this static class variable serves as this class's ID
128 * for ICU "poor man's RTTI".
130 static const char fgClassID
;
133 inline UBool
NamePrepTransform::isLDHChar(UChar32 ch
){
138 //[\\u002D \\u0030-\\u0039 \\u0041-\\u005A \\u0061-\\u007A]
140 (0x0030 <= ch
&& ch
<= 0x0039) ||
141 (0x0041 <= ch
&& ch
<= 0x005A) ||
142 (0x0061 <= ch
&& ch
<= 0x007A)
149 #endif /* #if !UCONFIG_NO_TRANSLITERATION */
151 class NamePrepTransform
{
153 #endif /* #if !UCONFIG_NO_IDNA */
158 * Hey, Emacs, please set the following:
161 * indent-tabs-mode: nil