2 *******************************************************************************
4 * Copyright (C) 2003, 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"
31 #define ASCII_SPACE 0x0020
33 class NamePrepTransform
{
36 Transliterator
*mapping
;
37 UnicodeSet unassigned
;
38 UnicodeSet prohibited
;
39 UnicodeSet labelSeparatorSet
;
40 UResourceBundle
*bundle
;
41 NamePrepTransform(UParseError
& parseError
, UErrorCode
& status
);
46 static NamePrepTransform
* createInstance(UParseError
& parseError
, UErrorCode
& status
);
48 virtual ~NamePrepTransform();
51 inline UBool
isProhibited(UChar32 ch
);
54 * ICU "poor man's RTTI", returns a UClassID for the actual class.
58 inline UClassID
getDynamicClassID() const { return getStaticClassID(); }
61 * ICU "poor man's RTTI", returns a UClassID for this class.
65 static inline UClassID
getStaticClassID() { return (UClassID
)&fgClassID
; }
68 * Map every character in input stream with mapping character
69 * in the mapping table and populate the output stream.
70 * For any individual character the mapping table may specify
71 * that that a character be mapped to nothing, mapped to one
72 * other character or to a string of other characters.
74 * @param src Pointer to UChar buffer containing a single label
75 * @param srcLength Number of characters in the source label
76 * @param dest Pointer to the destination buffer to receive the output
77 * @param destCapacity The capacity of destination array
78 * @param allowUnassigned Unassigned values can be converted to ASCII for query operations
79 * If TRUE unassigned values are treated as normal Unicode code point.
80 * If FALSE the operation fails with U_UNASSIGNED_CODE_POINT_FOUND error code.
81 * @param status ICU error code in/out parameter.
82 * Must fulfill U_SUCCESS before the function call.
83 * @return The number of UChars in the destination buffer
86 int32_t map(const UChar
* src
, int32_t srcLength
,
87 UChar
* dest
, int32_t destCapacity
,
88 UBool allowUnassigned
,
89 UParseError
* parseError
,
93 * Prepare the input stream with for use. This operation maps, normalizes(NFKC),
94 * checks for prohited and BiDi characters in the order defined by RFC 3454
96 * @param src Pointer to UChar buffer containing a single label
97 * @param srcLength Number of characters in the source label
98 * @param dest Pointer to the destination buffer to receive the output
99 * @param destCapacity The capacity of destination array
100 * @param allowUnassigned Unassigned values can be converted to ASCII for query operations
101 * If TRUE unassigned values are treated as normal Unicode code point.
102 * If FALSE the operation fails with U_UNASSIGNED_CODE_POINT error code.
103 * @param status ICU error code in/out parameter.
104 * Must fulfill U_SUCCESS before the function call.
105 * @return The number of UChars in the destination buffer
107 int32_t process(const UChar
* src
, int32_t srcLength
,
108 UChar
* dest
, int32_t destCapacity
,
109 UBool allowUnassigned
,
110 UParseError
* parseError
,
111 UErrorCode
& status
);
114 * Ascertain if the given code point is a label separator as specified by IDNA
116 * @return TRUE is the code point is a label separator
120 UBool
isLabelSeparator(UChar32 ch
, UErrorCode
& status
);
123 inline UBool
isLDHChar(UChar32 ch
);
126 * The address of this static class variable serves as this class's ID
127 * for ICU "poor man's RTTI".
129 static const char fgClassID
;
132 inline UBool
NamePrepTransform::isLDHChar(UChar32 ch
){
137 //[\\u002D \\u0030-\\u0039 \\u0041-\\u005A \\u0061-\\u007A]
139 (0x0030 <= ch
&& ch
<= 0x0039) ||
140 (0x0041 <= ch
&& ch
<= 0x005A) ||
141 (0x0061 <= ch
&& ch
<= 0x007A)
148 #endif /* #if !UCONFIG_NO_TRANSLITERATION */
150 class NamePrepTransform
{
152 #endif /* #if !UCONFIG_NO_IDNA */
157 * Hey, Emacs, please set the following:
160 * indent-tabs-mode: nil