Class Normalizer
- All Implemented Interfaces:
Cloneable
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 are two exceptions: The new API does not provide a replacement for
QuickCheckResult
and compare()
.
normalize
transforms Unicode text into an equivalent composed or
decomposed form, allowing for easier sorting and searching of text.
normalize
supports the standard normalization forms described in
Unicode Standard Annex #15 — Unicode Normalization Forms.
Characters with accents or other adornments can be encoded in several different ways in Unicode. For example, take the character A-acute. In Unicode, this can be encoded as a single character (the "composed" form):
00C1 LATIN CAPITAL LETTER A WITH ACUTEor as two separate characters (the "decomposed" form):
0041 LATIN CAPITAL LETTER A 0301 COMBINING ACUTE ACCENT
To a user of your program, however, both of these sequences should be treated as the same "user-level" character "A with acute accent". When you are searching or comparing text, you must ensure that these two sequences are treated equivalently. In addition, you must handle characters with more than one accent. Sometimes the order of a character's combining accents is significant, while in other cases accent sequences in different orders are really equivalent.
Similarly, the string "ffi" can be encoded as three separate letters:
0066 LATIN SMALL LETTER F 0066 LATIN SMALL LETTER F 0069 LATIN SMALL LETTER Ior as the single character
FB03 LATIN SMALL LIGATURE FFI
The ffi ligature is not a distinct semantic character, and strictly speaking it shouldn't be in Unicode at all, but it was included for compatibility with existing character sets that already provided it. The Unicode standard identifies such characters by giving them "compatibility" decompositions into the corresponding semantic characters. When sorting and searching, you will often want to use these mappings.
normalize
helps solve these problems by transforming text into
the canonical composed and decomposed forms as shown in the first example
above. In addition, you can have it perform compatibility decompositions so
that you can treat compatibility characters the same as their equivalents.
Finally, normalize
rearranges accents into the proper canonical
order, so that you do not have to worry about accent rearrangement on your
own.
Form FCD, "Fast C or D", is also designed for collation. It allows to work on strings that are not necessarily normalized with an algorithm (like in collation) that works under "canonical closure", i.e., it treats precomposed characters and their decomposed equivalents the same.
It is not a normalization form because it does not provide for uniqueness of representation. Multiple strings may be canonically equivalent (their NFDs are identical) and may all conform to FCD without being identical themselves.
The form is defined such that the "raw decomposition", the recursive canonical decomposition of each character, results in a string that is canonically ordered. This means that precomposed characters are allowed for as long as their decompositions do not need canonical reordering.
Its advantage for a process like collation is that all NFD and most NFC texts - and many unnormalized texts - already conform to FCD and do not need to be normalized (NFD) for such a process. The FCD quick check will return YES for most strings in practice.
normalize(FCD) may be implemented with NFD.
For more details on FCD see Unicode Technical Note #5 (Canonical Equivalence in Applications): http://www.unicode.org/notes/tn5/#FCD
ICU collation performs either NFD or FCD normalization automatically if normalization is turned on for the collator object. Beyond collation and string search, normalized strings may be useful for string equivalence comparisons, transliteration/transcription, unique representations, etc.
The W3C generally recommends to exchange texts in NFC. Note also that most legacy character encodings use only precomposed forms and often do not encode any combining marks by themselves. For conversion to such character encodings the Unicode text needs to be normalized to NFC. For more usage examples, see the Unicode Standard Annex.
Note: The Normalizer class also provides API for iterative normalization. While the setIndex() and getIndex() refer to indices in the underlying Unicode input text, the next() and previous() methods iterate through characters in the normalized output. This means that there is not necessarily a one-to-one correspondence between characters returned by next() and previous() and the indices passed to and returned from setIndex() and getIndex(). It is for this reason that Normalizer does not implement the CharacterIterator interface.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Deprecated.static final class
Result values for quickCheck(). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Option bit for compare: Compare strings in code point order instead of code unit order.static final int
Option bit for compare: Perform case-insensitive comparison.static final int
Deprecated.ICU 56 UseNormalizer2
instead.static final Normalizer.Mode
Deprecated.ICU 2.8.static final Normalizer.Mode
Deprecated.ICU 2.8.static final Normalizer.Mode
Deprecated.ICU 2.8.static final Normalizer.Mode
Deprecated.ICU 2.8.static final Normalizer.Mode
Deprecated.ICU 56 UseNormalizer2
instead.static final int
Deprecated.ICU 56static final Normalizer.Mode
Deprecated.ICU 56 UseNormalizer2
instead.static final int
Option bit for compare: Case sensitively compare the stringsstatic final int
Option value for case folding: Use the modified set of mappings provided in CaseFolding.txt to handle dotted I and dotless i appropriately for Turkic languages (tr, az).static final int
Deprecated.ICU 2.8.static final int
Option bit for compare: Both input strings are assumed to fulfill FCD conditions.static final Normalizer.QuickCheckResult
Indicates it cannot be determined if string is in the normalized format without further thorough checks.static final Normalizer.Mode
Deprecated.ICU 56 UseNormalizer2
instead.static final Normalizer.Mode
Deprecated.ICU 56 UseNormalizer2
instead.static final Normalizer.Mode
Deprecated.ICU 56 UseNormalizer2
instead.static final Normalizer.Mode
Deprecated.ICU 56 UseNormalizer2
instead.static final Normalizer.QuickCheckResult
Indicates that string is not in the normalized formatstatic final Normalizer.Mode
Deprecated.ICU 2.8.static final Normalizer.Mode
Deprecated.ICU 56 UseNormalizer2
instead.static final int
Deprecated.ICU 56 UseFilteredNormalizer2
instead.static final Normalizer.QuickCheckResult
Indicates that string is in the normalized format -
Constructor Summary
ConstructorsConstructorDescriptionNormalizer
(UCharacterIterator iter, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Normalizer
(String str, Normalizer.Mode mode, int opt) Deprecated.ICU 56 UseNormalizer2
instead.Normalizer
(CharacterIterator iter, Normalizer.Mode mode, int opt) Deprecated.ICU 56 UseNormalizer2
instead. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Deprecated.ICU 56 UseNormalizer2
instead.static int
compare
(char[] s1, char[] s2, int options) Compare two strings for canonical equivalence.static int
compare
(char[] s1, int s1Start, int s1Limit, char[] s2, int s2Start, int s2Limit, int options) Compare two strings for canonical equivalence.static int
compare
(int char32a, int char32b, int options) Convenience method that can have faster implementation by not allocating buffers.static int
Convenience method that can have faster implementation by not allocating buffers.static int
Compare two strings for canonical equivalence.static int
compose
(char[] source, char[] target, boolean compat, int options) Deprecated.ICU 56 UseNormalizer2
instead.static int
compose
(char[] src, int srcStart, int srcLimit, char[] dest, int destStart, int destLimit, boolean compat, int options) Deprecated.ICU 56 UseNormalizer2
instead.static String
Deprecated.ICU 56 UseNormalizer2
instead.static String
Deprecated.ICU 56 UseNormalizer2
instead.static String
concatenate
(char[] left, char[] right, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.static int
concatenate
(char[] left, int leftStart, int leftLimit, char[] right, int rightStart, int rightLimit, char[] dest, int destStart, int destLimit, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.static String
concatenate
(String left, String right, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.int
current()
Deprecated.ICU 56static int
decompose
(char[] source, char[] target, boolean compat, int options) Deprecated.ICU 56 UseNormalizer2
instead.static int
decompose
(char[] src, int srcStart, int srcLimit, char[] dest, int destStart, int destLimit, boolean compat, int options) Deprecated.ICU 56 UseNormalizer2
instead.static String
Deprecated.ICU 56 UseNormalizer2
instead.static String
Deprecated.ICU 56 UseNormalizer2
instead.int
endIndex()
Deprecated.ICU 56int
first()
Deprecated.ICU 56int
Deprecated.ICU 2.2.int
Deprecated.ICU 2.2.static String
getFC_NFKC_Closure
(int c) Deprecated.ICU 56static int
getFC_NFKC_Closure
(int c, char[] dest) Deprecated.ICU 56int
getIndex()
Deprecated.ICU 56int
Deprecated.ICU 56getMode()
Deprecated.ICU 56int
getOption
(int option) Deprecated.ICU 56getText()
Deprecated.ICU 56int
getText
(char[] fillIn) Deprecated.ICU 56static boolean
isNormalized
(char[] src, int start, int limit, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.static boolean
isNormalized
(int char32, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.static boolean
isNormalized
(String str, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.int
last()
Deprecated.ICU 56int
next()
Deprecated.ICU 56static int
normalize
(char[] source, char[] target, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.static int
normalize
(char[] src, int srcStart, int srcLimit, char[] dest, int destStart, int destLimit, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.static String
normalize
(int char32, Normalizer.Mode mode) Deprecated.ICU 56 UseNormalizer2
instead.static String
normalize
(int char32, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.static String
normalize
(String src, Normalizer.Mode mode) Deprecated.ICU 56 UseNormalizer2
instead.static String
normalize
(String str, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.int
previous()
Deprecated.ICU 56static Normalizer.QuickCheckResult
quickCheck
(char[] source, int start, int limit, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.static Normalizer.QuickCheckResult
quickCheck
(char[] source, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.static Normalizer.QuickCheckResult
quickCheck
(String source, Normalizer.Mode mode) Deprecated.ICU 56 UseNormalizer2
instead.static Normalizer.QuickCheckResult
quickCheck
(String source, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.void
reset()
Deprecated.ICU 56int
setIndex
(int index) Deprecated.ICU 3.2void
setIndexOnly
(int index) Deprecated.ICU 56void
setMode
(Normalizer.Mode newMode) Deprecated.ICU 56void
setOption
(int option, boolean value) Deprecated.ICU 56void
setText
(char[] newText) Deprecated.ICU 56void
setText
(UCharacterIterator newText) Deprecated.ICU 56void
Deprecated.ICU 56void
setText
(StringBuffer newText) Deprecated.ICU 56void
setText
(CharacterIterator newText) Deprecated.ICU 56int
Deprecated.ICU 56
-
Field Details
-
UNICODE_3_2
Deprecated.ICU 56 UseFilteredNormalizer2
instead.Options bit set value to select Unicode 3.2 normalization (except NormalizationCorrections). At most one Unicode version can be selected at a time.- See Also:
-
DONE
Deprecated.ICU 56Constant indicating that the end of the iteration has been reached. This is guaranteed to have the same value asUForwardCharacterIterator.DONE
.- See Also:
-
NONE
Deprecated.ICU 56 UseNormalizer2
instead.No decomposition/composition. -
NFD
Deprecated.ICU 56 UseNormalizer2
instead.Canonical decomposition. -
NFKD
Deprecated.ICU 56 UseNormalizer2
instead.Compatibility decomposition. -
NFC
Deprecated.ICU 56 UseNormalizer2
instead.Canonical decomposition followed by canonical composition. -
DEFAULT
Deprecated.ICU 56 UseNormalizer2
instead.Default normalization. -
NFKC
Deprecated.ICU 56 UseNormalizer2
instead.Compatibility decomposition followed by canonical composition. -
FCD
Deprecated.ICU 56 UseNormalizer2
instead."Fast C or D" form. -
NO_OP
Deprecated.ICU 2.8. Use Nomalizer.NONENull operation for use with theconstructors
and the staticnormalize
method. This value tells the Normalizer to do nothing but return unprocessed characters from the underlying String or CharacterIterator. If you have code which requires raw text at some times and normalized text at others, you can use NO_OP for the cases where you want raw text, rather than having a separate code path that bypasses Normalizer altogether.- See Also:
-
COMPOSE
Deprecated.ICU 2.8. Use Normalier.NFCCanonical decomposition followed by canonical composition. Used with theconstructors
and the staticnormalize
method to determine the operation to be performed.If all optional features (e.g.
IGNORE_HANGUL
) are turned off, this operation produces output that is in Unicode Canonical Form C.- See Also:
-
COMPOSE_COMPAT
Deprecated.ICU 2.8. Use Normalizer.NFKCCompatibility decomposition followed by canonical composition. Used with theconstructors
and the staticnormalize
method to determine the operation to be performed.If all optional features (e.g.
IGNORE_HANGUL
) are turned off, this operation produces output that is in Unicode Canonical Form KC.- See Also:
-
DECOMP
Deprecated.ICU 2.8. Use Normalizer.NFDCanonical decomposition. This value is passed to theconstructors
and the staticnormalize
method to determine the operation to be performed.If all optional features (e.g.
IGNORE_HANGUL
) are turned off, this operation produces output that is in Unicode Canonical Form D.- See Also:
-
DECOMP_COMPAT
Deprecated.ICU 2.8. Use Normalizer.NFKDCompatibility decomposition. This value is passed to theconstructors
and the staticnormalize
method to determine the operation to be performed.If all optional features (e.g.
IGNORE_HANGUL
) are turned off, this operation produces output that is in Unicode Canonical Form KD.- See Also:
-
IGNORE_HANGUL
Deprecated.ICU 2.8. This option is no longer supported.Option to disable Hangul/Jamo composition and decomposition. This option applies to Korean text, which can be represented either in the Jamo alphabet or in Hangul characters, which are really just two or three Jamo combined into one visual glyph. Since Jamo takes up more storage space than Hangul, applications that process only Hangul text may wish to turn this option on when decomposing text.The Unicode standard treats Hangul to Jamo conversion as a canonical decomposition, so this option must be turned off if you wish to transform strings into one of the standard Unicode Normalization Forms.
- See Also:
-
NO
Indicates that string is not in the normalized format -
YES
Indicates that string is in the normalized format -
MAYBE
Indicates it cannot be determined if string is in the normalized format without further thorough checks. -
FOLD_CASE_DEFAULT
public static final int FOLD_CASE_DEFAULTOption bit for compare: Case sensitively compare the strings- See Also:
-
INPUT_IS_FCD
public static final int INPUT_IS_FCDOption bit for compare: Both input strings are assumed to fulfill FCD conditions.- See Also:
-
COMPARE_IGNORE_CASE
public static final int COMPARE_IGNORE_CASEOption bit for compare: Perform case-insensitive comparison.- See Also:
-
COMPARE_CODE_POINT_ORDER
public static final int COMPARE_CODE_POINT_ORDEROption bit for compare: Compare strings in code point order instead of code unit order.- See Also:
-
FOLD_CASE_EXCLUDE_SPECIAL_I
public static final int FOLD_CASE_EXCLUDE_SPECIAL_IOption value for case folding: Use the modified set of mappings provided in CaseFolding.txt to handle dotted I and dotless i appropriately for Turkic languages (tr, az).- See Also:
-
COMPARE_NORM_OPTIONS_SHIFT
Deprecated.ICU 56 UseNormalizer2
instead.Lowest-order bit number of compare() options bits corresponding to normalization options bits. The options parameter for compare() uses most bits for itself and for various comparison and folding flags. The most significant bits, however, are shifted down and passed on to the normalization implementation. (That is, from compare(..., options, ...), options>>COMPARE_NORM_OPTIONS_SHIFT will be passed on to the internal normalization functions.)- See Also:
-
-
Constructor Details
-
Normalizer
Deprecated.ICU 56 UseNormalizer2
instead.Creates a new Normalizer object for iterating over the normalized form of a given string.The options parameter specifies which optional Normalizer features are to be enabled for this object.
- Parameters:
str
- The string to be normalized. The normalization will start at the beginning of the string.mode
- The normalization mode.opt
- Any optional features to be enabled. Currently the only available option isUNICODE_3_2
. If you want the default behavior corresponding to one of the standard Unicode Normalization Forms, use 0 for this argument.
-
Normalizer
Deprecated.ICU 56 UseNormalizer2
instead.Creates a new Normalizer object for iterating over the normalized form of the given text.- Parameters:
iter
- The input text to be normalized. The normalization will start at the beginning of the string.mode
- The normalization mode.opt
- Any optional features to be enabled. Currently the only available option isUNICODE_3_2
. If you want the default behavior corresponding to one of the standard Unicode Normalization Forms, use 0 for this argument.
-
Normalizer
Deprecated.ICU 56 UseNormalizer2
instead.Creates a new Normalizer object for iterating over the normalized form of the given text.- Parameters:
iter
- The input text to be normalized. The normalization will start at the beginning of the string.mode
- The normalization mode.options
- The normalization options, ORed together (0 for no options).
-
-
Method Details
-
clone
Deprecated.ICU 56 UseNormalizer2
instead.Clones this Normalizer object. All properties of this object are duplicated in the new object, including the cloning of anyCharacterIterator
that was passed in to the constructor or tosetText
. However, the text storage underlying the CharacterIterator is not duplicated unless the iterator's clone method does so. -
compose
Deprecated.ICU 56 UseNormalizer2
instead.Compose a string. The string will be composed to according to the specified mode.- Parameters:
str
- The string to compose.compat
- If true the string will be composed according to NFKC rules and if false will be composed according to NFC rules.- Returns:
- String The composed string
-
compose
Deprecated.ICU 56 UseNormalizer2
instead.Compose a string. The string will be composed to according to the specified mode.- Parameters:
str
- The string to compose.compat
- If true the string will be composed according to NFKC rules and if false will be composed according to NFC rules.options
- The only recognized option is UNICODE_3_2- Returns:
- String The composed string
-
compose
Deprecated.ICU 56 UseNormalizer2
instead.Compose a string. The string will be composed to according to the specified mode.- Parameters:
source
- The char array to compose.target
- A char buffer to receive the normalized text.compat
- If true the char array will be composed according to NFKC rules and if false will be composed according to NFC rules.options
- The normalization options, ORed together (0 for no options).- Returns:
- int The total buffer size needed;if greater than length of result, the output was truncated.
- Throws:
IndexOutOfBoundsException
- if target.length is less than the required length
-
compose
@Deprecated public static int compose(char[] src, int srcStart, int srcLimit, char[] dest, int destStart, int destLimit, boolean compat, int options) Deprecated.ICU 56 UseNormalizer2
instead.Compose a string. The string will be composed to according to the specified mode.- Parameters:
src
- The char array to compose.srcStart
- Start index of the sourcesrcLimit
- Limit index of the sourcedest
- The char buffer to fill indestStart
- Start index of the destination bufferdestLimit
- End index of the destination buffercompat
- If true the char array will be composed according to NFKC rules and if false will be composed according to NFC rules.options
- The normalization options, ORed together (0 for no options).- Returns:
- int The total buffer size needed;if greater than length of result, the output was truncated.
- Throws:
IndexOutOfBoundsException
- if target.length is less than the required length
-
decompose
Deprecated.ICU 56 UseNormalizer2
instead.Decompose a string. The string will be decomposed to according to the specified mode.- Parameters:
str
- The string to decompose.compat
- If true the string will be decomposed according to NFKD rules and if false will be decomposed according to NFD rules.- Returns:
- String The decomposed string
-
decompose
Deprecated.ICU 56 UseNormalizer2
instead.Decompose a string. The string will be decomposed to according to the specified mode.- Parameters:
str
- The string to decompose.compat
- If true the string will be decomposed according to NFKD rules and if false will be decomposed according to NFD rules.options
- The normalization options, ORed together (0 for no options).- Returns:
- String The decomposed string
-
decompose
Deprecated.ICU 56 UseNormalizer2
instead.Decompose a string. The string will be decomposed to according to the specified mode.- Parameters:
source
- The char array to decompose.target
- A char buffer to receive the normalized text.compat
- If true the char array will be decomposed according to NFKD rules and if false will be decomposed according to NFD rules.options
- The normalization options, ORed together (0 for no options).- Returns:
- int The total buffer size needed;if greater than length of result,the output was truncated.
- Throws:
IndexOutOfBoundsException
- if the target capacity is less than the required length
-
decompose
@Deprecated public static int decompose(char[] src, int srcStart, int srcLimit, char[] dest, int destStart, int destLimit, boolean compat, int options) Deprecated.ICU 56 UseNormalizer2
instead.Decompose a string. The string will be decomposed to according to the specified mode.- Parameters:
src
- The char array to compose.srcStart
- Start index of the sourcesrcLimit
- Limit index of the sourcedest
- The char buffer to fill indestStart
- Start index of the destination bufferdestLimit
- End index of the destination buffercompat
- If true the char array will be decomposed according to NFKD rules and if false will be decomposed according to NFD rules.options
- The normalization options, ORed together (0 for no options).- Returns:
- int The total buffer size needed;if greater than length of result,the output was truncated.
- Throws:
IndexOutOfBoundsException
- if the target capacity is less than the required length
-
normalize
Deprecated.ICU 56 UseNormalizer2
instead.Normalizes a String using the given normalization operation.The options parameter specifies which optional Normalizer features are to be enabled for this operation. Currently the only available option is
UNICODE_3_2
. If you want the default behavior corresponding to one of the standard Unicode Normalization Forms, use 0 for this argument.- Parameters:
str
- the input string to be normalized.mode
- the normalization modeoptions
- the optional features to be enabled.- Returns:
- String the normalized string
-
normalize
Deprecated.ICU 56 UseNormalizer2
instead.Normalize a string. The string will be normalized according to the specified normalization mode and options.- Parameters:
src
- The string to normalize.mode
- The normalization mode; one of Normalizer.NONE, Normalizer.NFD, Normalizer.NFC, Normalizer.NFKC, Normalizer.NFKD, Normalizer.DEFAULT- Returns:
- the normalized string
-
normalize
@Deprecated public static int normalize(char[] source, char[] target, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Normalize a string. The string will be normalized according to the specified normalization mode and options.- Parameters:
source
- The char array to normalize.target
- A char buffer to receive the normalized text.mode
- The normalization mode; one of Normalizer.NONE, Normalizer.NFD, Normalizer.NFC, Normalizer.NFKC, Normalizer.NFKD, Normalizer.DEFAULToptions
- The normalization options, ORed together (0 for no options).- Returns:
- int The total buffer size needed;if greater than length of result, the output was truncated.
- Throws:
IndexOutOfBoundsException
- if the target capacity is less than the required length
-
normalize
@Deprecated public static int normalize(char[] src, int srcStart, int srcLimit, char[] dest, int destStart, int destLimit, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Normalize a string. The string will be normalized according to the specified normalization mode and options.- Parameters:
src
- The char array to compose.srcStart
- Start index of the sourcesrcLimit
- Limit index of the sourcedest
- The char buffer to fill indestStart
- Start index of the destination bufferdestLimit
- End index of the destination buffermode
- The normalization mode; one of Normalizer.NONE, Normalizer.NFD, Normalizer.NFC, Normalizer.NFKC, Normalizer.NFKD, Normalizer.DEFAULToptions
- The normalization options, ORed together (0 for no options).- Returns:
- int The total buffer size needed;if greater than length of result, the output was truncated.
- Throws:
IndexOutOfBoundsException
- if the target capacity is less than the required length
-
normalize
Deprecated.ICU 56 UseNormalizer2
instead.Normalize a codepoint according to the given mode- Parameters:
char32
- The input string to be normalized.mode
- The normalization modeoptions
- Options for use with exclusion set and tailored Normalization The only option that is currently recognized is UNICODE_3_2- Returns:
- String The normalized string
- See Also:
-
normalize
Deprecated.ICU 56 UseNormalizer2
instead.Convenience method to normalize a codepoint according to the given mode- Parameters:
char32
- The input string to be normalized.mode
- The normalization mode- Returns:
- String The normalized string
-
quickCheck
@Deprecated public static Normalizer.QuickCheckResult quickCheck(String source, Normalizer.Mode mode) Deprecated.ICU 56 UseNormalizer2
instead.Convenience method.- Parameters:
source
- string for determining if it is in a normalized formatmode
- normalization format (Normalizer.NFC,Normalizer.NFD, Normalizer.NFKC,Normalizer.NFKD)- Returns:
- Return code to specify if the text is normalized or not (Normalizer.YES, Normalizer.NO or Normalizer.MAYBE)
-
quickCheck
@Deprecated public static Normalizer.QuickCheckResult quickCheck(String source, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Performing quick check on a string, to quickly determine if the string is in a particular normalization format. Three types of result can be returned Normalizer.YES, Normalizer.NO or Normalizer.MAYBE. Result Normalizer.YES indicates that the argument string is in the desired normalized format, Normalizer.NO determines that argument string is not in the desired normalized format. A Normalizer.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 results.- Parameters:
source
- string for determining if it is in a normalized formatmode
- normalization format (Normalizer.NFC,Normalizer.NFD, Normalizer.NFKC,Normalizer.NFKD)options
- Options for use with exclusion set and tailored Normalization The only option that is currently recognized is UNICODE_3_2- Returns:
- Return code to specify if the text is normalized or not (Normalizer.YES, Normalizer.NO or Normalizer.MAYBE)
-
quickCheck
@Deprecated public static Normalizer.QuickCheckResult quickCheck(char[] source, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Convenience method.- Parameters:
source
- Array of characters for determining if it is in a normalized formatmode
- normalization format (Normalizer.NFC,Normalizer.NFD, Normalizer.NFKC,Normalizer.NFKD)options
- Options for use with exclusion set and tailored Normalization The only option that is currently recognized is UNICODE_3_2- Returns:
- Return code to specify if the text is normalized or not (Normalizer.YES, Normalizer.NO or Normalizer.MAYBE)
-
quickCheck
@Deprecated public static Normalizer.QuickCheckResult quickCheck(char[] source, int start, int limit, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Performing quick check on a string, to quickly determine if the string is in a particular normalization format. Three types of result can be returned Normalizer.YES, Normalizer.NO or Normalizer.MAYBE. Result Normalizer.YES indicates that the argument string is in the desired normalized format, Normalizer.NO determines that argument string is not in the desired normalized format. A Normalizer.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 results.- Parameters:
source
- string for determining if it is in a normalized formatstart
- the start index of the sourcelimit
- the limit index of the source it is equal to the lengthmode
- normalization format (Normalizer.NFC,Normalizer.NFD, Normalizer.NFKC,Normalizer.NFKD)options
- Options for use with exclusion set and tailored Normalization The only option that is currently recognized is UNICODE_3_2- Returns:
- Return code to specify if the text is normalized or not (Normalizer.YES, Normalizer.NO or Normalizer.MAYBE)
-
isNormalized
@Deprecated public static boolean isNormalized(char[] src, int start, int limit, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Test if a string is in a given normalization form. This is semantically equivalent to source.equals(normalize(source, mode)). Unlike 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.- Parameters:
src
- The input array of characters to be checked to see if it is normalizedstart
- The strart index in the sourcelimit
- The limit index in the sourcemode
- the normalization modeoptions
- Options for use with exclusion set and tailored Normalization The only option that is currently recognized is UNICODE_3_2- Returns:
- Boolean value indicating whether the source string is in the "mode" normalization form
-
isNormalized
Deprecated.ICU 56 UseNormalizer2
instead.Test if a string is in a given normalization form. This is semantically equivalent to source.equals(normalize(source, mode)). Unlike 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.- Parameters:
str
- the input string to be checked to see if it is normalizedmode
- the normalization modeoptions
- Options for use with exclusion set and tailored Normalization The only option that is currently recognized is UNICODE_3_2- See Also:
-
isNormalized
Deprecated.ICU 56 UseNormalizer2
instead.Convenience Method- Parameters:
char32
- the input code point to be checked to see if it is normalizedmode
- the normalization modeoptions
- Options for use with exclusion set and tailored Normalization The only option that is currently recognized is UNICODE_3_2- See Also:
-
compare
public static int compare(char[] s1, int s1Start, int s1Limit, char[] s2, int s2Start, int s2Limit, int options) 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 strcmp[CodePointOrder](foldCase(NFD(s1)), foldCase(NFD(s2))) where code point order and foldCase are all optional.- Parameters:
s1
- First source character array.s1Start
- start index of sources1Limit
- limit of the sources2
- Second source character array.s2Start
- start index of the sources2Limit
- limit of the sourceoptions
- A bit set of options: - 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. - 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. - COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order - 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.- Returns:
- <0 or 0 or >0 as usual for string comparisons
- See Also:
-
compare
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 strcmp[CodePointOrder](foldCase(NFD(s1)), foldCase(NFD(s2))) where code point order and foldCase are all optional.- Parameters:
s1
- First source string.s2
- Second source string.options
- A bit set of options: - 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. - 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. - COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order - 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.- Returns:
- <0 or 0 or >0 as usual for string comparisons
- See Also:
-
compare
public static int compare(char[] s1, char[] s2, int options) Compare two strings for canonical equivalence. Further options include case-insensitive comparison and code point order (as opposed to code unit order). Convenience method.- Parameters:
s1
- First source string.s2
- Second source string.options
- A bit set of options: - 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. - 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. - COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order - 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.- Returns:
- <0 or 0 or >0 as usual for string comparisons
- See Also:
-
compare
public static int compare(int char32a, int char32b, int options) Convenience method that can have faster implementation by not allocating buffers.- Parameters:
char32a
- the first code point to be checked against thechar32b
- the second code pointoptions
- A bit set of options
-
compare
Convenience method that can have faster implementation by not allocating buffers.- Parameters:
char32a
- the first code point to be checked againststr2
- the second stringoptions
- A bit set of options
-
concatenate
@Deprecated public static int concatenate(char[] left, int leftStart, int leftLimit, char[] right, int rightStart, int rightLimit, char[] dest, int destStart, int destLimit, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Concatenate normalized strings, making sure that the result is normalized as well. If both the left and the right strings are in the normalization form according to "mode", then the result will bedest=normalize(left+right, mode)
With the input strings already being normalized, this function will use next() and previous() to find the adjacent end pieces of the input strings. Only the concatenation of these end pieces will be normalized and then concatenated with the remaining parts of the input strings. It is allowed to have dest==left to avoid copying the entire left string.- Parameters:
left
- Left source array, may be same as dest.leftStart
- start in the left array.leftLimit
- limit in the left array (==length)right
- Right source array.rightStart
- start in the right array.rightLimit
- limit in the right array (==length)dest
- The output buffer; can be null if destStart==destLimit==0 for pure preflighting.destStart
- start in the destination arraydestLimit
- limit in the destination array (==length)mode
- The normalization mode.options
- The normalization options, ORed together (0 for no options).- Returns:
- Length of output (number of chars) when successful or IndexOutOfBoundsException
- Throws:
IndexOutOfBoundsException
- whose message has the string representation of destination capacity required.IndexOutOfBoundsException
- if target capacity is less than the required length- See Also:
-
concatenate
@Deprecated public static String concatenate(char[] left, char[] right, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Concatenate normalized strings, making sure that the result is normalized as well. If both the left and the right strings are in the normalization form according to "mode", then the result will bedest=normalize(left+right, mode)
For details see concatenate- Parameters:
left
- Left source string.right
- Right source string.mode
- The normalization mode.options
- The normalization options, ORed together (0 for no options).- Returns:
- result
- See Also:
-
concatenate
@Deprecated public static String concatenate(String left, String right, Normalizer.Mode mode, int options) Deprecated.ICU 56 UseNormalizer2
instead.Concatenate normalized strings, making sure that the result is normalized as well. If both the left and the right strings are in the normalization form according to "mode", then the result will bedest=normalize(left+right, mode)
With the input strings already being normalized, this function will use next() and previous() to find the adjacent end pieces of the input strings. Only the concatenation of these end pieces will be normalized and then concatenated with the remaining parts of the input strings.- Parameters:
left
- Left source string.right
- Right source string.mode
- The normalization mode.options
- The normalization options, ORed together (0 for no options).- Returns:
- result
- See Also:
-
getFC_NFKC_Closure
Deprecated.ICU 56Gets the FC_NFKC closure value.- Parameters:
c
- The code point whose closure value is to be retrieveddest
- The char array to receive the closure value- Returns:
- the length of the closure value; 0 if there is none
-
getFC_NFKC_Closure
Deprecated.ICU 56Gets the FC_NFKC closure value.- Parameters:
c
- The code point whose closure value is to be retrieved- Returns:
- String representation of the closure value; "" if there is none
-
current
Deprecated.ICU 56Return the current character in the normalized text.- Returns:
- The codepoint as an int
-
next
Deprecated.ICU 56Return the next character in the normalized text and advance the iteration position by one. If the end of the text has already been reached,DONE
is returned.- Returns:
- The codepoint as an int
-
previous
Deprecated.ICU 56Return the previous character in the normalized text and decrement the iteration position by one. If the beginning of the text has already been reached,DONE
is returned.- Returns:
- The codepoint as an int
-
reset
Deprecated.ICU 56Reset the index to the beginning of the text. This is equivalent to setIndexOnly(startIndex)). -
setIndexOnly
Deprecated.ICU 56Set 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.- Parameters:
index
- the desired index in the input text.
-
setIndex
Deprecated.ICU 3.2Set the iteration position in the input text that is being normalized and return the first normalized character at that position.Note: This method sets the position in the input text, while
next()
andprevious()
iterate through characters in the normalized output. This means that there is not necessarily a one-to-one correspondence between characters returned by next and previous and the indices passed to and returned from setIndex andgetIndex()
.- Parameters:
index
- the desired index in the input text.- Returns:
- the first normalized character that is the result of iterating forward starting at the given index.
- Throws:
IllegalArgumentException
- if the given index is less thangetBeginIndex()
or greater thangetEndIndex()
.
-
getBeginIndex
Deprecated.ICU 2.2. Use startIndex() instead.Retrieve the index of the start of the input text. This is the begin index of the CharacterIterator or the start (i.e. 0) of the String over which this Normalizer is iterating- Returns:
- The codepoint as an int
- See Also:
-
getEndIndex
Deprecated.ICU 2.2. Use endIndex() instead.Retrieve the index of the end of the input text. This is the end index of the CharacterIterator or the length of the String over which this Normalizer is iterating- Returns:
- The codepoint as an int
- See Also:
-
first
Deprecated.ICU 56Return the first character in the normalized text. This resets the Normalizer's position to the beginning of the text.- Returns:
- The codepoint as an int
-
last
Deprecated.ICU 56Return the last character in the normalized text. This resets the Normalizer's position to be just before the the input text corresponding to that normalized character.- Returns:
- The codepoint as an int
-
getIndex
Deprecated.ICU 56Retrieve the current iteration position in the input text that is being normalized. This method is useful in applications such as searching, where you need to be able to determine the position in the input text that corresponds to a given normalized output character.Note: This method sets the position in the input, while
next()
andprevious()
iterate through characters in the output. This means that there is not necessarily a one-to-one correspondence between characters returned by next and previous and the indices passed to and returned from setIndex andgetIndex()
.- Returns:
- The current iteration position
-
startIndex
Deprecated.ICU 56Retrieve the index of the start of the input text. This is the begin index of the CharacterIterator or the start (i.e. 0) of the String over which this Normalizer is iterating- Returns:
- The current iteration position
-
endIndex
Deprecated.ICU 56Retrieve the index of the end of the input text. This is the end index of the CharacterIterator or the length of the String over which this Normalizer is iterating- Returns:
- The current iteration position
-
setMode
Deprecated.ICU 56Set the normalization mode for this object.Note:If the normalization mode is changed while iterating over a string, calls to
next()
andprevious()
may return previously buffers characters in the old normalization mode until the iteration is able to re-sync at the next base character. It is safest to callsetText()
,first()
,last()
, etc. after calling setMode.- Parameters:
newMode
- the new mode for this Normalizer. The supported modes are:NFC
- Unicode canonical decompositiion followed by canonical composition.NFKC
- Unicode compatibility decompositiion followed by canonical composition.NFD
- Unicode canonical decompositionNFKD
- Unicode compatibility decomposition.NONE
- Do nothing but return characters from the underlying input text.
- See Also:
-
getMode
Deprecated.ICU 56Return the basic operation performed by this Normalizer- See Also:
-
setOption
Deprecated.ICU 56Set options that affect this Normalizer's operation. Options do not change the basic composition or decomposition operation that is being performed , but they control whether certain optional portions of the operation are done. Currently the only available option is:UNICODE_3_2
- Use Normalization conforming to Unicode version 3.2.
- Parameters:
option
- the option whose value is to be set.value
- the new setting for the option. Use true to turn the option on and false to turn it off.- See Also:
-
getOption
Deprecated.ICU 56Determine whether an option is turned on or off.- See Also:
-
getText
Deprecated.ICU 56Gets the underlying text storage- Parameters:
fillIn
- the char buffer to fill the UTF-16 units. The length of the buffer should be equal to the length of the underlying text storage- Throws:
IndexOutOfBoundsException
- If the index passed for the array is invalid.- See Also:
-
getLength
Deprecated.ICU 56Gets the length of underlying text storage- Returns:
- the length
-
getText
Deprecated.ICU 56Returns the text under iteration as a string- Returns:
- a copy of the text under iteration.
-
setText
Deprecated.ICU 56Set the input text over which this Normalizer will iterate. The iteration position is set to the beginning of the input text.- Parameters:
newText
- The new string to be normalized.
-
setText
Deprecated.ICU 56Set the input text over which this Normalizer will iterate. The iteration position is set to the beginning of the input text.- Parameters:
newText
- The new string to be normalized.
-
setText
Deprecated.ICU 56Set the input text over which this Normalizer will iterate. The iteration position is set to the beginning of the input text.- Parameters:
newText
- The new string to be normalized.
-
setText
Deprecated.ICU 56Set the input text over which this Normalizer will iterate. The iteration position is set to the beginning of the input text.- Parameters:
newText
- The new string to be normalized.
-
setText
Deprecated.ICU 56Set the input text over which this Normalizer will iterate. The iteration position is set to the beginning of the string.- Parameters:
newText
- The new string to be normalized.
-
Normalizer2
instead.