ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

normalizer2.h
Go to the documentation of this file.
1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 * Copyright (C) 2009-2013, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 * file name: normalizer2.h
11 * encoding: US-ASCII
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 2009nov22
16 * created by: Markus W. Scherer
17 */
18
19 #ifndef __NORMALIZER2_H__
20 #define __NORMALIZER2_H__
21
27 #include "unicode/utypes.h"
28
29 #if !UCONFIG_NO_NORMALIZATION
30
31 #include "unicode/uniset.h"
32 #include "unicode/unistr.h"
33 #include "unicode/unorm2.h"
34
35 U_NAMESPACE_BEGIN
36
80 class U_COMMON_API Normalizer2 : public UObject {
81 public:
86 ~Normalizer2();
87
99 static const Normalizer2 *
100 getNFCInstance(UErrorCode &errorCode);
101
113 static const Normalizer2 *
114 getNFDInstance(UErrorCode &errorCode);
115
127 static const Normalizer2 *
128 getNFKCInstance(UErrorCode &errorCode);
129
141 static const Normalizer2 *
142 getNFKDInstance(UErrorCode &errorCode);
143
155 static const Normalizer2 *
156 getNFKCCasefoldInstance(UErrorCode &errorCode);
157
179 static const Normalizer2 *
180 getInstance(const char *packageName,
181 const char *name,
182 UNormalization2Mode mode,
183 UErrorCode &errorCode);
184
195 UnicodeString
196 normalize(const UnicodeString &src, UErrorCode &errorCode) const {
197 UnicodeString result;
198 normalize(src, result, errorCode);
199 return result;
200 }
214 virtual UnicodeString &
215 normalize(const UnicodeString &src,
216 UnicodeString &dest,
217 UErrorCode &errorCode) const = 0;
232 virtual UnicodeString &
233 normalizeSecondAndAppend(UnicodeString &first,
234 const UnicodeString &second,
235 UErrorCode &errorCode) const = 0;
250 virtual UnicodeString &
251 append(UnicodeString &first,
252 const UnicodeString &second,
253 UErrorCode &errorCode) const = 0;
254
268 virtual UBool
269 getDecomposition(UChar32 c, UnicodeString &decomposition) const = 0;
270
295 virtual UBool
296 getRawDecomposition(UChar32 c, UnicodeString &decomposition) const;
297
313 virtual UChar32
314 composePair(UChar32 a, UChar32 b) const;
315
324 virtual uint8_t
325 getCombiningClass(UChar32 c) const;
326
341 virtual UBool
342 isNormalized(const UnicodeString &s, UErrorCode &errorCode) const = 0;
343
359 virtual UNormalizationCheckResult
360 quickCheck(const UnicodeString &s, UErrorCode &errorCode) const = 0;
361
384 virtual int32_t
385 spanQuickCheckYes(const UnicodeString &s, UErrorCode &errorCode) const = 0;
386
400 virtual UBool hasBoundaryBefore(UChar32 c) const = 0;
401
416 virtual UBool hasBoundaryAfter(UChar32 c) const = 0;
417
431 virtual UBool isInert(UChar32 c) const = 0;
432 };
433
445 class U_COMMON_API FilteredNormalizer2 : public Normalizer2 {
446 public:
457 FilteredNormalizer2(const Normalizer2 &n2, const UnicodeSet &filterSet) :
458 norm2(n2), set(filterSet) {}
459
464 ~FilteredNormalizer2();
465
479 virtual UnicodeString &
480 normalize(const UnicodeString &src,
481 UnicodeString &dest,
482 UErrorCode &errorCode) const;
497 virtual UnicodeString &
498 normalizeSecondAndAppend(UnicodeString &first,
499 const UnicodeString &second,
500 UErrorCode &errorCode) const;
515 virtual UnicodeString &
516 append(UnicodeString &first,
517 const UnicodeString &second,
518 UErrorCode &errorCode) const;
519
531 virtual UBool
532 getDecomposition(UChar32 c, UnicodeString &decomposition) const;
533
545 virtual UBool
546 getRawDecomposition(UChar32 c, UnicodeString &decomposition) const;
547
558 virtual UChar32
559 composePair(UChar32 a, UChar32 b) const;
560
569 virtual uint8_t
570 getCombiningClass(UChar32 c) const;
571
583 virtual UBool
584 isNormalized(const UnicodeString &s, UErrorCode &errorCode) const;
596 virtual UNormalizationCheckResult
597 quickCheck(const UnicodeString &s, UErrorCode &errorCode) const;
609 virtual int32_t
610 spanQuickCheckYes(const UnicodeString &s, UErrorCode &errorCode) const;
611
620 virtual UBool hasBoundaryBefore(UChar32 c) const;
621
630 virtual UBool hasBoundaryAfter(UChar32 c) const;
631
639 virtual UBool isInert(UChar32 c) const;
640 private:
641 UnicodeString &
642 normalize(const UnicodeString &src,
643 UnicodeString &dest,
644 USetSpanCondition spanCondition,
645 UErrorCode &errorCode) const;
646
647 UnicodeString &
648 normalizeSecondAndAppend(UnicodeString &first,
649 const UnicodeString &second,
650 UBool doNormalize,
651 UErrorCode &errorCode) const;
652
653 const Normalizer2 &norm2;
654 const UnicodeSet &set;
655 };
656
657 U_NAMESPACE_END
658
659 #endif // !UCONFIG_NO_NORMALIZATION
660 #endif // __NORMALIZER2_H__
icu::Normalizer2::getRawDecomposition
virtual UBool getRawDecomposition(UChar32 c, UnicodeString &decomposition) const
Gets the raw decomposition mapping of c.
icu::Normalizer2::hasBoundaryBefore
virtual UBool hasBoundaryBefore(UChar32 c) const =0
Tests if the character always has a normalization boundary before it, regardless of context...
icu::Normalizer2::normalize
UnicodeString normalize(const UnicodeString &src, UErrorCode &errorCode) const
Returns the normalized form of the source string.
Definition: normalizer2.h:196
icu::Normalizer2::composePair
virtual UChar32 composePair(UChar32 a, UChar32 b) const
Performs pairwise composition of a & b and returns the composite if there is one. ...
icu::Normalizer2::spanQuickCheckYes
virtual int32_t spanQuickCheckYes(const UnicodeString &s, UErrorCode &errorCode) const =0
Returns the end of the normalized substring of the input string.
unistr.h
C++ API: Unicode String.
icu::Normalizer2::append
virtual UnicodeString & append(UnicodeString &first, const UnicodeString &second, UErrorCode &errorCode) const =0
Appends the second string to the first string (merging them at the boundary) and returns the first st...
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
icu::Normalizer2
Unicode normalization functionality for standard Unicode normalization or for using custom mapping ta...
Definition: normalizer2.h:80
unorm2.h
C API: New API for Unicode Normalization.
icu::Normalizer2::hasBoundaryAfter
virtual UBool hasBoundaryAfter(UChar32 c) const =0
Tests if the character always has a normalization boundary after it, regardless of context...
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:357
icu::FilteredNormalizer2::FilteredNormalizer2
FilteredNormalizer2(const Normalizer2 &n2, const UnicodeSet &filterSet)
Constructs a filtered normalizer wrapping any Normalizer2 instance and a filter set.
Definition: normalizer2.h:457
icu::UnicodeSet
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:278
USetSpanCondition
USetSpanCondition
Argument values for whether span() and similar functions continue while the current character is cont...
Definition: uset.h:152
icu::Normalizer2::quickCheck
virtual UNormalizationCheckResult quickCheck(const UnicodeString &s, UErrorCode &errorCode) const =0
Tests if the string is normalized.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UNormalization2Mode
UNormalization2Mode
Constants for normalization modes.
Definition: unorm2.h:44
icu::Normalizer2::normalizeSecondAndAppend
virtual UnicodeString & normalizeSecondAndAppend(UnicodeString &first, const UnicodeString &second, UErrorCode &errorCode) const =0
Appends the normalized form of the second string to the first string (merging them at the boundary) a...
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
icu::Normalizer2::isNormalized
virtual UBool isNormalized(const UnicodeString &s, UErrorCode &errorCode) const =0
Tests if the string is normalized.
icu::Normalizer2::getDecomposition
virtual UBool getDecomposition(UChar32 c, UnicodeString &decomposition) const =0
Gets the decomposition mapping of c.
icu::Normalizer2::getCombiningClass
virtual uint8_t getCombiningClass(UChar32 c) const
Gets the combining class of c.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::Normalizer2::isInert
virtual UBool isInert(UChar32 c) const =0
Tests if the character is normalization-inert.
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:359
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::FilteredNormalizer2
Normalization filtered by a UnicodeSet.
Definition: normalizer2.h:445
UNormalizationCheckResult
UNormalizationCheckResult
Result values for normalization quick check functions.
Definition: unorm2.h:93
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259
uniset.h
C++ API: Unicode Set.