1999-12-28 23:39:02 +00:00
|
|
|
/*
|
|
|
|
********************************************************************
|
2004-08-24 17:21:14 +00:00
|
|
|
* COPYRIGHT:
|
2010-01-06 23:50:03 +00:00
|
|
|
* Copyright (c) 1996-2010, International Business Machines Corporation and
|
1999-12-28 23:39:02 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NORMLZR_H
|
|
|
|
#define NORMLZR_H
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
2003-05-06 01:22:23 +00:00
|
|
|
|
2005-06-22 22:39:36 +00:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief C++ API: Unicode Normalization
|
|
|
|
*/
|
|
|
|
|
2003-05-06 01:22:23 +00:00
|
|
|
#if !UCONFIG_NO_NORMALIZATION
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/chariter.h"
|
2010-01-06 23:50:03 +00:00
|
|
|
#include "unicode/normalizer2.h"
|
|
|
|
#include "unicode/unistr.h"
|
2001-02-03 01:25:27 +00:00
|
|
|
#include "unicode/unorm.h"
|
2010-01-06 23:50:03 +00:00
|
|
|
#include "unicode/uobject.h"
|
2001-10-19 17:36:02 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2006-01-18 06:37:07 +00:00
|
|
|
* The Normalizer class supports the standard normalization forms described in
|
|
|
|
* <a href="http://www.unicode.org/unicode/reports/tr15/" target="unicode">
|
2006-01-18 07:02:22 +00:00
|
|
|
* Unicode Standard Annex #15: Unicode Normalization Forms</a>.
|
2001-06-21 18:02:53 +00:00
|
|
|
*
|
2010-01-06 23:50:03 +00:00
|
|
|
* Note: This API has been replaced by the Normalizer2 class and is only available
|
|
|
|
* for backward compatibility. This class simply delegates to the Normalizer2 class.
|
|
|
|
* There is one exception: The new API does not provide a replacement for Normalizer::compare().
|
|
|
|
*
|
2001-09-27 21:04:40 +00:00
|
|
|
* The Normalizer class consists of two parts:
|
|
|
|
* - static functions that normalize strings or test if strings are normalized
|
|
|
|
* - a Normalizer object is an iterator that takes any kind of text and
|
|
|
|
* provides iteration over its normalized form
|
|
|
|
*
|
2002-11-07 02:38:51 +00:00
|
|
|
* The Normalizer class is not suitable for subclassing.
|
|
|
|
*
|
2001-09-27 21:04:40 +00:00
|
|
|
* For basic information about normalization forms and details about the C API
|
|
|
|
* please see the documentation in unorm.h.
|
|
|
|
*
|
|
|
|
* The iterator API with the Normalizer constructors and the non-static functions
|
2010-01-06 23:50:03 +00:00
|
|
|
* use a CharacterIterator as input. It is possible to pass a string which
|
2001-09-27 21:04:40 +00:00
|
|
|
* is then internally wrapped in a CharacterIterator.
|
|
|
|
* The input text is not normalized all at once, but incrementally where needed
|
|
|
|
* (providing efficient random access).
|
|
|
|
* This allows to pass in a large text but spend only a small amount of time
|
|
|
|
* normalizing a small part of that text.
|
|
|
|
* However, if the entire text is normalized, then the iterator will be
|
|
|
|
* slower than normalizing the entire text at once and iterating over the result.
|
|
|
|
* A possible use of the Normalizer iterator is also to report an index into the
|
|
|
|
* original text that is close to where the normalized characters come from.
|
|
|
|
*
|
|
|
|
* <em>Important:</em> The iterator API was cleaned up significantly for ICU 2.0.
|
|
|
|
* The earlier implementation reported the getIndex() inconsistently,
|
|
|
|
* and previous() could not be used after setIndex(), next(), first(), and current().
|
|
|
|
*
|
|
|
|
* Normalizer allows to start normalizing from anywhere in the input text by
|
2002-08-21 19:12:24 +00:00
|
|
|
* calling setIndexOnly(), first(), or last().
|
2001-09-27 21:04:40 +00:00
|
|
|
* Without calling any of these, the iterator will start at the beginning of the text.
|
|
|
|
*
|
|
|
|
* At any time, next() returns the next normalized code point (UChar32),
|
|
|
|
* with post-increment semantics (like CharacterIterator::next32PostInc()).
|
|
|
|
* previous() returns the previous normalized code point (UChar32),
|
|
|
|
* with pre-decrement semantics (like CharacterIterator::previous32()).
|
|
|
|
*
|
2002-08-21 19:12:24 +00:00
|
|
|
* current() returns the current code point
|
2001-09-27 21:04:40 +00:00
|
|
|
* (respectively the one at the newly set index) without moving
|
|
|
|
* the getIndex(). Note that if the text at the current position
|
|
|
|
* needs to be normalized, then these functions will do that.
|
|
|
|
* (This is why current() is not const.)
|
|
|
|
* It is more efficient to call setIndexOnly() instead, which does not
|
|
|
|
* normalize.
|
|
|
|
*
|
|
|
|
* getIndex() always refers to the position in the input text where the normalized
|
|
|
|
* code points are returned from. It does not always change with each returned
|
|
|
|
* code point.
|
|
|
|
* The code point that is returned from any of the functions
|
|
|
|
* corresponds to text at or after getIndex(), according to the
|
|
|
|
* function's iteration semantics (post-increment or pre-decrement).
|
|
|
|
*
|
|
|
|
* next() returns a code point from at or after the getIndex()
|
|
|
|
* from before the next() call. After the next() call, the getIndex()
|
|
|
|
* might have moved to where the next code point will be returned from
|
|
|
|
* (from a next() or current() call).
|
|
|
|
* This is semantically equivalent to array access with array[index++]
|
|
|
|
* (post-increment semantics).
|
|
|
|
*
|
|
|
|
* previous() returns a code point from at or after the getIndex()
|
|
|
|
* from after the previous() call.
|
|
|
|
* This is semantically equivalent to array access with array[--index]
|
|
|
|
* (pre-decrement semantics).
|
|
|
|
*
|
|
|
|
* Internally, the Normalizer iterator normalizes a small piece of text
|
|
|
|
* starting at the getIndex() and ending at a following "safe" index.
|
|
|
|
* The normalized results is stored in an internal string buffer, and
|
|
|
|
* the code points are iterated from there.
|
|
|
|
* With multiple iteration calls, this is repeated until the next piece
|
|
|
|
* of text needs to be normalized, and the getIndex() needs to be moved.
|
|
|
|
*
|
|
|
|
* The following "safe" index, the internal buffer, and the secondary
|
|
|
|
* iteration index into that buffer are not exposed on the API.
|
|
|
|
* This also means that it is currently not practical to return to
|
|
|
|
* a particular, arbitrary position in the text because one would need to
|
|
|
|
* know, and be able to set, in addition to the getIndex(), at least also the
|
|
|
|
* current index into the internal buffer.
|
|
|
|
* It is currently only possible to observe when getIndex() changes
|
|
|
|
* (with careful consideration of the iteration semantics),
|
|
|
|
* at which time the internal index will be 0.
|
|
|
|
* For example, if getIndex() is different after next() than before it,
|
|
|
|
* then the internal index is 0 and one can return to this getIndex()
|
|
|
|
* later with setIndexOnly().
|
2001-06-21 18:02:53 +00:00
|
|
|
*
|
|
|
|
* @author Laura Werner, Mark Davis, Markus Scherer
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-06-27 01:19:20 +00:00
|
|
|
class U_COMMON_API Normalizer : public UObject {
|
2001-09-25 22:45:26 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* If DONE is returned from an iteration function that returns a code point,
|
|
|
|
* then there are no more normalization results available.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-25 22:45:26 +00:00
|
|
|
*/
|
2000-05-24 20:56:19 +00:00
|
|
|
enum {
|
|
|
|
DONE=0xffff
|
|
|
|
};
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
// Constructors
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Creates a new <code>Normalizer</code> object for iterating over the
|
1999-12-28 23:39:02 +00:00
|
|
|
* normalized form of a given string.
|
|
|
|
* <p>
|
|
|
|
* @param str The string to be normalized. The normalization
|
|
|
|
* will start at the beginning of the string.
|
|
|
|
*
|
|
|
|
* @param mode The normalization mode.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2001-09-25 22:45:26 +00:00
|
|
|
Normalizer(const UnicodeString& str, UNormalizationMode mode);
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Creates a new <code>Normalizer</code> object for iterating over the
|
|
|
|
* normalized form of a given string.
|
2000-03-22 18:31:40 +00:00
|
|
|
* <p>
|
|
|
|
* @param str The string to be normalized. The normalization
|
|
|
|
* will start at the beginning of the string.
|
|
|
|
*
|
2001-09-27 21:04:40 +00:00
|
|
|
* @param length Length of the string, or -1 if NUL-terminated.
|
2000-03-22 18:31:40 +00:00
|
|
|
* @param mode The normalization mode.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2001-09-25 22:45:26 +00:00
|
|
|
Normalizer(const UChar* str, int32_t length, UNormalizationMode mode);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Creates a new <code>Normalizer</code> object for iterating over the
|
1999-12-28 23:39:02 +00:00
|
|
|
* normalized form of the given text.
|
|
|
|
* <p>
|
|
|
|
* @param iter The input text to be normalized. The normalization
|
|
|
|
* will start at the beginning of the string.
|
|
|
|
*
|
|
|
|
* @param mode The normalization mode.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2001-09-25 22:45:26 +00:00
|
|
|
Normalizer(const CharacterIterator& iter, UNormalizationMode mode);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Copy constructor.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param copy The object to be copied.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
Normalizer(const Normalizer& copy);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Destructor
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-26 20:39:32 +00:00
|
|
|
virtual ~Normalizer();
|
2000-08-11 21:56:35 +00:00
|
|
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Static utility methods
|
|
|
|
//-------------------------------------------------------------------------
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Normalizes a <code>UnicodeString</code> according to the specified normalization mode.
|
|
|
|
* This is a wrapper for unorm_normalize(), using UnicodeString's.
|
2003-03-13 23:01:42 +00:00
|
|
|
*
|
2001-09-27 21:04:40 +00:00
|
|
|
* The <code>options</code> parameter specifies which optional
|
|
|
|
* <code>Normalizer</code> features are to be enabled for this operation.
|
2003-03-13 23:01:42 +00:00
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param source the input string to be normalized.
|
2001-09-27 21:04:40 +00:00
|
|
|
* @param mode the normalization mode
|
|
|
|
* @param options the optional features to be enabled (0 for no options)
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param result The normalized string (on output).
|
|
|
|
* @param status The error code.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static void U_EXPORT2 normalize(const UnicodeString& source,
|
2001-09-25 22:45:26 +00:00
|
|
|
UNormalizationMode mode, int32_t options,
|
|
|
|
UnicodeString& result,
|
|
|
|
UErrorCode &status);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Compose a <code>UnicodeString</code>.
|
|
|
|
* This is equivalent to normalize() with mode UNORM_NFC or UNORM_NFKC.
|
|
|
|
* This is a wrapper for unorm_normalize(), using UnicodeString's.
|
2003-03-13 23:01:42 +00:00
|
|
|
*
|
2001-09-27 21:04:40 +00:00
|
|
|
* The <code>options</code> parameter specifies which optional
|
|
|
|
* <code>Normalizer</code> features are to be enabled for this operation.
|
2003-03-13 23:01:42 +00:00
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param source the string to be composed.
|
|
|
|
* @param compat Perform compatibility decomposition before composition.
|
2001-09-27 21:04:40 +00:00
|
|
|
* If this argument is <code>FALSE</code>, only canonical
|
1999-12-28 23:39:02 +00:00
|
|
|
* decomposition will be performed.
|
2001-09-27 21:04:40 +00:00
|
|
|
* @param options the optional features to be enabled (0 for no options)
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param result The composed string (on output).
|
|
|
|
* @param status The error code.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static void U_EXPORT2 compose(const UnicodeString& source,
|
2001-09-25 22:45:26 +00:00
|
|
|
UBool compat, int32_t options,
|
|
|
|
UnicodeString& result,
|
|
|
|
UErrorCode &status);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Static method to decompose a <code>UnicodeString</code>.
|
|
|
|
* This is equivalent to normalize() with mode UNORM_NFD or UNORM_NFKD.
|
|
|
|
* This is a wrapper for unorm_normalize(), using UnicodeString's.
|
2003-03-13 23:01:42 +00:00
|
|
|
*
|
2001-09-27 21:04:40 +00:00
|
|
|
* The <code>options</code> parameter specifies which optional
|
|
|
|
* <code>Normalizer</code> features are to be enabled for this operation.
|
2003-03-13 23:01:42 +00:00
|
|
|
*
|
2001-09-27 21:04:40 +00:00
|
|
|
* @param source the string to be decomposed.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param compat Perform compatibility decomposition.
|
2001-09-27 21:04:40 +00:00
|
|
|
* If this argument is <code>FALSE</code>, only canonical
|
1999-12-28 23:39:02 +00:00
|
|
|
* decomposition will be performed.
|
2001-09-27 21:04:40 +00:00
|
|
|
* @param options the optional features to be enabled (0 for no options)
|
|
|
|
* @param result The decomposed string (on output).
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param status The error code.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static void U_EXPORT2 decompose(const UnicodeString& source,
|
2001-09-25 22:45:26 +00:00
|
|
|
UBool compat, int32_t options,
|
|
|
|
UnicodeString& result,
|
|
|
|
UErrorCode &status);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Performing quick check on a string, to quickly determine if the string is
|
2001-09-25 22:45:26 +00:00
|
|
|
* in a particular normalization format.
|
2001-09-27 21:04:40 +00:00
|
|
|
* This is a wrapper for unorm_quickCheck(), using a UnicodeString.
|
|
|
|
*
|
2001-09-25 22:45:26 +00:00
|
|
|
* Three types of result can be returned UNORM_YES, UNORM_NO or
|
|
|
|
* UNORM_MAYBE. Result UNORM_YES indicates that the argument
|
|
|
|
* string is in the desired normalized format, UNORM_NO determines that
|
2004-08-24 17:21:14 +00:00
|
|
|
* argument string is not in the desired normalized format. A
|
|
|
|
* UNORM_MAYBE result indicates that a more thorough check is required,
|
|
|
|
* the user may have to put the string in its normalized form and compare the
|
2001-09-25 22:45:26 +00:00
|
|
|
* results.
|
|
|
|
* @param source string for determining if it is in a normalized format
|
2003-05-10 00:06:12 +00:00
|
|
|
* @param mode normalization format
|
2002-06-12 03:29:09 +00:00
|
|
|
* @param status A reference to a UErrorCode to receive any errors
|
2001-09-25 22:45:26 +00:00
|
|
|
* @return UNORM_YES, UNORM_NO or UNORM_MAYBE
|
2002-06-12 03:29:09 +00:00
|
|
|
*
|
|
|
|
* @see isNormalized
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-25 22:45:26 +00:00
|
|
|
*/
|
2002-06-12 03:29:09 +00:00
|
|
|
static inline UNormalizationCheckResult
|
2001-09-25 22:45:26 +00:00
|
|
|
quickCheck(const UnicodeString &source, UNormalizationMode mode, UErrorCode &status);
|
2001-02-03 01:25:27 +00:00
|
|
|
|
2003-03-13 23:01:42 +00:00
|
|
|
/**
|
|
|
|
* Performing quick check on a string; same as the other version of quickCheck
|
|
|
|
* but takes an extra options parameter like most normalization functions.
|
|
|
|
*
|
|
|
|
* @param source string for determining if it is in a normalized format
|
2003-05-10 00:06:12 +00:00
|
|
|
* @param mode normalization format
|
2003-03-13 23:01:42 +00:00
|
|
|
* @param options the optional features to be enabled (0 for no options)
|
|
|
|
* @param status A reference to a UErrorCode to receive any errors
|
|
|
|
* @return UNORM_YES, UNORM_NO or UNORM_MAYBE
|
|
|
|
*
|
|
|
|
* @see isNormalized
|
2004-11-02 07:28:07 +00:00
|
|
|
* @stable ICU 2.6
|
2003-03-13 23:01:42 +00:00
|
|
|
*/
|
2010-01-06 23:50:03 +00:00
|
|
|
static UNormalizationCheckResult
|
2003-02-26 01:45:06 +00:00
|
|
|
quickCheck(const UnicodeString &source, UNormalizationMode mode, int32_t options, UErrorCode &status);
|
|
|
|
|
2002-06-12 03:29:09 +00:00
|
|
|
/**
|
|
|
|
* Test if a string is in a given normalization form.
|
|
|
|
* This is semantically equivalent to source.equals(normalize(source, mode)) .
|
|
|
|
*
|
|
|
|
* Unlike unorm_quickCheck(), this function returns a definitive result,
|
|
|
|
* never a "maybe".
|
|
|
|
* For NFD, NFKD, and FCD, both functions work exactly the same.
|
|
|
|
* For NFC and NFKC where quickCheck may return "maybe", this function will
|
|
|
|
* perform further tests to arrive at a TRUE/FALSE result.
|
|
|
|
*
|
|
|
|
* @param src String that is to be tested if it is in a normalization format.
|
2003-05-10 00:06:12 +00:00
|
|
|
* @param mode Which normalization form to test for.
|
2002-06-12 03:29:09 +00:00
|
|
|
* @param errorCode ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* @return Boolean value indicating whether the source string is in the
|
|
|
|
* "mode" normalization form.
|
|
|
|
*
|
|
|
|
* @see quickCheck
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-06-12 03:29:09 +00:00
|
|
|
*/
|
|
|
|
static inline UBool
|
|
|
|
isNormalized(const UnicodeString &src, UNormalizationMode mode, UErrorCode &errorCode);
|
|
|
|
|
2003-03-13 23:01:42 +00:00
|
|
|
/**
|
|
|
|
* Test if a string is in a given normalization form; same as the other version of isNormalized
|
|
|
|
* but takes an extra options parameter like most normalization functions.
|
|
|
|
*
|
|
|
|
* @param src String that is to be tested if it is in a normalization format.
|
2003-05-10 00:06:12 +00:00
|
|
|
* @param mode Which normalization form to test for.
|
2003-03-13 23:01:42 +00:00
|
|
|
* @param options the optional features to be enabled (0 for no options)
|
|
|
|
* @param errorCode ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* @return Boolean value indicating whether the source string is in the
|
|
|
|
* "mode" normalization form.
|
|
|
|
*
|
|
|
|
* @see quickCheck
|
2004-11-02 07:28:07 +00:00
|
|
|
* @stable ICU 2.6
|
2003-03-13 23:01:42 +00:00
|
|
|
*/
|
2010-01-06 23:50:03 +00:00
|
|
|
static UBool
|
2003-02-26 01:45:06 +00:00
|
|
|
isNormalized(const UnicodeString &src, UNormalizationMode mode, int32_t options, UErrorCode &errorCode);
|
|
|
|
|
2002-08-22 17:59:47 +00:00
|
|
|
/**
|
2002-03-12 23:00:16 +00:00
|
|
|
* Concatenate normalized strings, making sure that the result is normalized as well.
|
|
|
|
*
|
|
|
|
* If both the left and the right strings are in
|
2003-03-13 23:01:42 +00:00
|
|
|
* the normalization form according to "mode/options",
|
2002-03-12 23:00:16 +00:00
|
|
|
* then the result will be
|
|
|
|
*
|
|
|
|
* \code
|
2003-03-13 23:01:42 +00:00
|
|
|
* dest=normalize(left+right, mode, options)
|
2002-03-12 23:00:16 +00:00
|
|
|
* \endcode
|
|
|
|
*
|
|
|
|
* For details see unorm_concatenate in unorm.h.
|
|
|
|
*
|
|
|
|
* @param left Left source string.
|
|
|
|
* @param right Right source string.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param result The output string.
|
2002-03-12 23:00:16 +00:00
|
|
|
* @param mode The normalization mode.
|
|
|
|
* @param options A bit set of normalization options.
|
2003-05-10 00:06:12 +00:00
|
|
|
* @param errorCode ICU error code in/out parameter.
|
2002-03-12 23:00:16 +00:00
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* @return result
|
|
|
|
*
|
|
|
|
* @see unorm_concatenate
|
|
|
|
* @see normalize
|
|
|
|
* @see unorm_next
|
|
|
|
* @see unorm_previous
|
|
|
|
*
|
2003-03-13 23:01:42 +00:00
|
|
|
* @stable ICU 2.1
|
2002-03-12 23:00:16 +00:00
|
|
|
*/
|
|
|
|
static UnicodeString &
|
2004-08-24 17:21:14 +00:00
|
|
|
U_EXPORT2 concatenate(UnicodeString &left, UnicodeString &right,
|
2002-03-12 23:00:16 +00:00
|
|
|
UnicodeString &result,
|
|
|
|
UNormalizationMode mode, int32_t options,
|
|
|
|
UErrorCode &errorCode);
|
|
|
|
|
2002-05-24 22:20:19 +00:00
|
|
|
/**
|
|
|
|
* Compare two strings for canonical equivalence.
|
|
|
|
* Further options include case-insensitive comparison and
|
|
|
|
* code point order (as opposed to code unit order).
|
|
|
|
*
|
|
|
|
* Canonical equivalence between two strings is defined as their normalized
|
|
|
|
* forms (NFD or NFC) being identical.
|
|
|
|
* This function compares strings incrementally instead of normalizing
|
|
|
|
* (and optionally case-folding) both strings entirely,
|
|
|
|
* improving performance significantly.
|
|
|
|
*
|
|
|
|
* Bulk normalization is only necessary if the strings do not fulfill the FCD
|
|
|
|
* conditions. Only in this case, and only if the strings are relatively long,
|
|
|
|
* is memory allocated temporarily.
|
|
|
|
* For FCD strings and short non-FCD strings there is no memory allocation.
|
|
|
|
*
|
|
|
|
* Semantically, this is equivalent to
|
2002-06-08 03:46:21 +00:00
|
|
|
* strcmp[CodePointOrder](NFD(foldCase(s1)), NFD(foldCase(s2)))
|
2002-05-24 22:20:19 +00:00
|
|
|
* where code point order and foldCase are all optional.
|
|
|
|
*
|
2002-06-08 03:46:21 +00:00
|
|
|
* UAX 21 2.5 Caseless Matching specifies that for a canonical caseless match
|
|
|
|
* the case folding must be performed first, then the normalization.
|
|
|
|
*
|
2002-05-24 22:20:19 +00:00
|
|
|
* @param s1 First source string.
|
|
|
|
* @param s2 Second source string.
|
|
|
|
*
|
|
|
|
* @param options A bit set of options:
|
|
|
|
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
|
|
|
* Case-sensitive comparison in code unit order, and the input strings
|
|
|
|
* are quick-checked for FCD.
|
|
|
|
*
|
|
|
|
* - UNORM_INPUT_IS_FCD
|
|
|
|
* Set if the caller knows that both s1 and s2 fulfill the FCD conditions.
|
|
|
|
* If not set, the function will quickCheck for FCD
|
|
|
|
* and normalize if necessary.
|
|
|
|
*
|
|
|
|
* - U_COMPARE_CODE_POINT_ORDER
|
|
|
|
* Set to choose code point order instead of code unit order
|
|
|
|
* (see u_strCompare for details).
|
|
|
|
*
|
|
|
|
* - U_COMPARE_IGNORE_CASE
|
|
|
|
* Set to compare strings case-insensitively using case folding,
|
|
|
|
* instead of case-sensitively.
|
|
|
|
* If set, then the following case folding options are used.
|
|
|
|
*
|
|
|
|
* - Options as used with case-insensitive comparisons, currently:
|
|
|
|
*
|
|
|
|
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
|
|
|
* (see u_strCaseCompare for details)
|
|
|
|
*
|
2003-03-13 23:01:42 +00:00
|
|
|
* - regular normalization options shifted left by UNORM_COMPARE_NORM_OPTIONS_SHIFT
|
|
|
|
*
|
2002-05-24 22:20:19 +00:00
|
|
|
* @param errorCode ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* @return <0 or 0 or >0 as usual for string comparisons
|
|
|
|
*
|
|
|
|
* @see unorm_compare
|
|
|
|
* @see normalize
|
|
|
|
* @see UNORM_FCD
|
|
|
|
* @see u_strCompare
|
|
|
|
* @see u_strCaseCompare
|
|
|
|
*
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-05-24 22:20:19 +00:00
|
|
|
*/
|
|
|
|
static inline int32_t
|
|
|
|
compare(const UnicodeString &s1, const UnicodeString &s2,
|
|
|
|
uint32_t options,
|
|
|
|
UErrorCode &errorCode);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2001-08-29 23:57:15 +00:00
|
|
|
// Iteration API
|
1999-12-28 23:39:02 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2004-08-24 17:21:14 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Return the current character in the normalized text.
|
2001-09-27 21:04:40 +00:00
|
|
|
* current() may need to normalize some text at getIndex().
|
|
|
|
* The getIndex() is not changed.
|
|
|
|
*
|
|
|
|
* @return the current normalized code point
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2001-08-29 23:57:15 +00:00
|
|
|
UChar32 current(void);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Return the first character in the normalized text.
|
|
|
|
* This is equivalent to setIndexOnly(startIndex()) followed by next().
|
|
|
|
* (Post-increment semantics.)
|
|
|
|
*
|
|
|
|
* @return the first normalized code point
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-24 20:56:19 +00:00
|
|
|
UChar32 first(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Return the last character in the normalized text.
|
|
|
|
* This is equivalent to setIndexOnly(endIndex()) followed by previous().
|
|
|
|
* (Pre-decrement semantics.)
|
|
|
|
*
|
|
|
|
* @return the last normalized code point
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-24 20:56:19 +00:00
|
|
|
UChar32 last(void);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Return the next character in the normalized text.
|
|
|
|
* (Post-increment semantics.)
|
2003-06-02 16:45:41 +00:00
|
|
|
* If the end of the text has already been reached, DONE is returned.
|
|
|
|
* The DONE value could be confused with a U+FFFF non-character code point
|
|
|
|
* in the text. If this is possible, you can test getIndex()<endIndex()
|
|
|
|
* before calling next(), or (getIndex()<endIndex() || last()!=DONE)
|
|
|
|
* after calling next(). (Calling last() will change the iterator state!)
|
|
|
|
*
|
|
|
|
* The C API unorm_next() is more efficient and does not have this ambiguity.
|
2001-09-27 21:04:40 +00:00
|
|
|
*
|
|
|
|
* @return the next normalized code point
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-24 20:56:19 +00:00
|
|
|
UChar32 next(void);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2003-06-02 16:45:41 +00:00
|
|
|
* Return the previous character in the normalized text and decrement.
|
2001-09-27 21:04:40 +00:00
|
|
|
* (Pre-decrement semantics.)
|
2003-06-02 16:45:41 +00:00
|
|
|
* If the beginning of the text has already been reached, DONE is returned.
|
|
|
|
* The DONE value could be confused with a U+FFFF non-character code point
|
|
|
|
* in the text. If this is possible, you can test
|
|
|
|
* (getIndex()>startIndex() || first()!=DONE). (Calling first() will change
|
|
|
|
* the iterator state!)
|
|
|
|
*
|
|
|
|
* The C API unorm_previous() is more efficient and does not have this ambiguity.
|
2001-09-27 21:04:40 +00:00
|
|
|
*
|
|
|
|
* @return the previous normalized code point
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-24 20:56:19 +00:00
|
|
|
UChar32 previous(void);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
2001-11-13 22:47:47 +00:00
|
|
|
/**
|
|
|
|
* Set the iteration position in the input text that is being normalized,
|
|
|
|
* without any immediate normalization.
|
|
|
|
* After setIndexOnly(), getIndex() will return the same index that is
|
|
|
|
* specified here.
|
|
|
|
*
|
|
|
|
* @param index the desired index in the input text.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-11-13 22:47:47 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
void setIndexOnly(int32_t index);
|
2001-08-29 23:57:15 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Reset the index to the beginning of the text.
|
|
|
|
* This is equivalent to setIndexOnly(startIndex)).
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void reset(void);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Retrieve the current iteration position in the input text that is
|
2001-09-27 21:04:40 +00:00
|
|
|
* being normalized.
|
|
|
|
*
|
|
|
|
* A following call to next() will return a normalized code point from
|
|
|
|
* the input text at or after this index.
|
|
|
|
*
|
|
|
|
* After a call to previous(), getIndex() will point at or before the
|
|
|
|
* position in the input text where the normalized code point
|
|
|
|
* was returned from with previous().
|
|
|
|
*
|
|
|
|
* @return the current index in the input text
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t getIndex(void) const;
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Retrieve the index of the start of the input text. This is the begin index
|
|
|
|
* of the <code>CharacterIterator</code> or the start (i.e. index 0) of the string
|
|
|
|
* over which this <code>Normalizer</code> is iterating.
|
|
|
|
*
|
|
|
|
* @return the smallest index in the input text where the Normalizer operates
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t startIndex(void) const;
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Retrieve the index of the end of the input text. This is the end index
|
|
|
|
* of the <code>CharacterIterator</code> or the length of the string
|
|
|
|
* over which this <code>Normalizer</code> is iterating.
|
|
|
|
* This end index is exclusive, i.e., the Normalizer operates only on characters
|
|
|
|
* before this index.
|
|
|
|
*
|
|
|
|
* @return the first index in the input text where the Normalizer does not operate
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t endIndex(void) const;
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Returns TRUE when both iterators refer to the same character in the same
|
|
|
|
* input text.
|
|
|
|
*
|
|
|
|
* @param that a Normalizer object to compare this one to
|
|
|
|
* @return comparison result
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool operator==(const Normalizer& that) const;
|
2001-09-27 21:04:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns FALSE when both iterators refer to the same character in the same
|
|
|
|
* input text.
|
|
|
|
*
|
|
|
|
* @param that a Normalizer object to compare this one to
|
|
|
|
* @return comparison result
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-27 21:04:40 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool operator!=(const Normalizer& that) const;
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Returns a pointer to a new Normalizer that is a clone of this one.
|
|
|
|
* The caller is responsible for deleting the new clone.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return a pointer to a new Normalizer
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
Normalizer* clone(void) const;
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Generates a hash code for this iterator.
|
2001-09-27 21:04:40 +00:00
|
|
|
*
|
|
|
|
* @return the hash code
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
int32_t hashCode(void) const;
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Property access methods
|
|
|
|
//-------------------------------------------------------------------------
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Set the normalization mode for this object.
|
|
|
|
* <p>
|
|
|
|
* <b>Note:</b>If the normalization mode is changed while iterating
|
2004-06-09 21:30:50 +00:00
|
|
|
* over a string, calls to {@link #next() } and {@link #previous() } may
|
1999-12-28 23:39:02 +00:00
|
|
|
* return previously buffers characters in the old normalization mode
|
|
|
|
* until the iteration is able to re-sync at the next base character.
|
2004-06-09 21:30:50 +00:00
|
|
|
* It is safest to call {@link #setIndexOnly }, {@link #reset() },
|
|
|
|
* {@link #setText }, {@link #first() },
|
|
|
|
* {@link #last() }, etc. after calling <code>setMode</code>.
|
1999-12-28 23:39:02 +00:00
|
|
|
* <p>
|
2001-09-27 21:04:40 +00:00
|
|
|
* @param newMode the new mode for this <code>Normalizer</code>.
|
2001-09-25 22:45:26 +00:00
|
|
|
* @see #getUMode
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2001-09-25 22:45:26 +00:00
|
|
|
void setMode(UNormalizationMode newMode);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Return the normalization mode for this object.
|
|
|
|
*
|
2001-09-25 22:45:26 +00:00
|
|
|
* This is an unusual name because there used to be a getMode() that
|
|
|
|
* returned a different type.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
2001-09-25 22:45:26 +00:00
|
|
|
* @return the mode for this <code>Normalizer</code>
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see #setMode
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2001-09-25 22:45:26 +00:00
|
|
|
UNormalizationMode getUMode(void) const;
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Set options that affect this <code>Normalizer</code>'s operation.
|
1999-12-28 23:39:02 +00:00
|
|
|
* Options do not change the basic composition or decomposition operation
|
2001-09-27 21:04:40 +00:00
|
|
|
* that is being performed, but they control whether
|
1999-12-28 23:39:02 +00:00
|
|
|
* certain optional portions of the operation are done.
|
2002-12-06 00:33:30 +00:00
|
|
|
* Currently the only available option is obsolete.
|
2001-09-25 22:45:26 +00:00
|
|
|
*
|
2001-09-27 21:04:40 +00:00
|
|
|
* It is possible to specify multiple options that are all turned on or off.
|
|
|
|
*
|
|
|
|
* @param option the option(s) whose value is/are to be set.
|
|
|
|
* @param value the new setting for the option. Use <code>TRUE</code> to
|
|
|
|
* turn the option(s) on and <code>FALSE</code> to turn it/them off.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @see #getOption
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
void setOption(int32_t option,
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool value);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Determine whether an option is turned on or off.
|
2001-09-27 21:04:40 +00:00
|
|
|
* If multiple options are specified, then the result is TRUE if any
|
|
|
|
* of them are set.
|
1999-12-28 23:39:02 +00:00
|
|
|
* <p>
|
2001-09-27 21:04:40 +00:00
|
|
|
* @param option the option(s) that are to be checked
|
|
|
|
* @return TRUE if any of the option(s) are set
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see #setOption
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool getOption(int32_t option) const;
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Set the input text over which this <code>Normalizer</code> will iterate.
|
1999-12-28 23:39:02 +00:00
|
|
|
* The iteration position is set to the beginning.
|
2001-09-27 21:04:40 +00:00
|
|
|
*
|
|
|
|
* @param newText a string that replaces the current input text
|
|
|
|
* @param status a UErrorCode
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
void setText(const UnicodeString& newText,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode &status);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Set the input text over which this <code>Normalizer</code> will iterate.
|
1999-12-28 23:39:02 +00:00
|
|
|
* The iteration position is set to the beginning.
|
2001-09-27 21:04:40 +00:00
|
|
|
*
|
|
|
|
* @param newText a CharacterIterator object that replaces the current input text
|
|
|
|
* @param status a UErrorCode
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
void setText(const CharacterIterator& newText,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode &status);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Set the input text over which this <code>Normalizer</code> will iterate.
|
1999-12-28 23:39:02 +00:00
|
|
|
* The iteration position is set to the beginning.
|
2001-09-27 21:04:40 +00:00
|
|
|
*
|
|
|
|
* @param newText a string that replaces the current input text
|
|
|
|
* @param length the length of the string, or -1 if NUL-terminated
|
|
|
|
* @param status a UErrorCode
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void setText(const UChar* newText,
|
|
|
|
int32_t length,
|
|
|
|
UErrorCode &status);
|
|
|
|
/**
|
2001-09-27 21:04:40 +00:00
|
|
|
* Copies the input text into the UnicodeString argument.
|
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param result Receives a copy of the text under iteration.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void getText(UnicodeString& result);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
/**
|
2003-08-27 01:01:42 +00:00
|
|
|
* ICU "poor man's RTTI", returns a UClassID for this class.
|
|
|
|
* @returns a UClassID for this class.
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-06-29 00:04:16 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static UClassID U_EXPORT2 getStaticClassID();
|
2002-06-29 00:04:16 +00:00
|
|
|
|
|
|
|
/**
|
2003-08-27 01:01:42 +00:00
|
|
|
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
|
|
|
* @return a UClassID for the actual class.
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-06-29 00:04:16 +00:00
|
|
|
*/
|
2003-08-27 01:01:42 +00:00
|
|
|
virtual UClassID getDynamicClassID() const;
|
2002-06-29 00:04:16 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
private:
|
2001-09-25 22:45:26 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Private functions
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2003-05-04 01:40:40 +00:00
|
|
|
Normalizer(); // default constructor not implemented
|
|
|
|
Normalizer &operator=(const Normalizer &that); // assignment operator not implemented
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
// Private utility methods for iteration
|
|
|
|
// For documentation, see the source code
|
2001-08-29 23:57:15 +00:00
|
|
|
UBool nextNormalize();
|
|
|
|
UBool previousNormalize();
|
2000-08-11 21:56:35 +00:00
|
|
|
|
2010-01-06 23:50:03 +00:00
|
|
|
void init();
|
1999-12-28 23:39:02 +00:00
|
|
|
void clearBuffer(void);
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Private data
|
|
|
|
//-------------------------------------------------------------------------
|
2000-08-11 21:56:35 +00:00
|
|
|
|
2010-01-06 23:50:03 +00:00
|
|
|
FilteredNormalizer2*fFilteredNorm2; // owned if not NULL
|
|
|
|
const Normalizer2 *fNorm2; // not owned; may be equal to fFilteredNorm2
|
2001-09-25 22:45:26 +00:00
|
|
|
UNormalizationMode fUMode;
|
|
|
|
int32_t fOptions;
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
// The input text and our position in it
|
2010-01-06 23:50:03 +00:00
|
|
|
CharacterIterator *text;
|
2001-09-11 01:29:36 +00:00
|
|
|
|
|
|
|
// The normalization buffer is the result of normalization
|
|
|
|
// of the source in [currentIndex..nextIndex[ .
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t currentIndex, nextIndex;
|
2000-08-11 21:56:35 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
// A buffer for holding intermediate results
|
|
|
|
UnicodeString buffer;
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t bufferPos;
|
1999-12-28 23:39:02 +00:00
|
|
|
};
|
|
|
|
|
2001-09-25 22:45:26 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Inline implementations
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
Normalizer::operator!= (const Normalizer& other) const
|
|
|
|
{ return ! operator==(other); }
|
|
|
|
|
2002-06-12 03:29:09 +00:00
|
|
|
inline UNormalizationCheckResult
|
|
|
|
Normalizer::quickCheck(const UnicodeString& source,
|
2004-08-24 17:21:14 +00:00
|
|
|
UNormalizationMode mode,
|
2002-06-12 03:29:09 +00:00
|
|
|
UErrorCode &status) {
|
2010-01-06 23:50:03 +00:00
|
|
|
return quickCheck(source, mode, 0, status);
|
2003-02-26 01:45:06 +00:00
|
|
|
}
|
|
|
|
|
2002-06-12 03:29:09 +00:00
|
|
|
inline UBool
|
|
|
|
Normalizer::isNormalized(const UnicodeString& source,
|
2004-08-24 17:21:14 +00:00
|
|
|
UNormalizationMode mode,
|
2002-06-12 03:29:09 +00:00
|
|
|
UErrorCode &status) {
|
2010-01-06 23:50:03 +00:00
|
|
|
return isNormalized(source, mode, 0, status);
|
2003-02-26 01:45:06 +00:00
|
|
|
}
|
|
|
|
|
2002-05-24 22:20:19 +00:00
|
|
|
inline int32_t
|
|
|
|
Normalizer::compare(const UnicodeString &s1, const UnicodeString &s2,
|
|
|
|
uint32_t options,
|
|
|
|
UErrorCode &errorCode) {
|
|
|
|
// all argument checking is done in unorm_compare
|
|
|
|
return unorm_compare(s1.getBuffer(), s1.length(),
|
|
|
|
s2.getBuffer(), s2.length(),
|
|
|
|
options,
|
|
|
|
&errorCode);
|
|
|
|
}
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
2003-05-06 01:22:23 +00:00
|
|
|
|
|
|
|
#endif /* #if !UCONFIG_NO_NORMALIZATION */
|
|
|
|
|
2003-05-01 01:51:51 +00:00
|
|
|
#endif // NORMLZR_H
|