Last active
May 15, 2023 15:55
-
-
Save dehidehidehi/2ca5ba62249b6cab283f6467cc0ff90e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Normalizes a {@link CharSequence} using the {@link Normalizer.Form#NFKC} method; | |
* It is a Unicode normalization form that replaces characters with their | |
* compatibility equivalents and then applies canonical composition. | |
* This method is useful for ensuring that strings containing different | |
* representations of the same characters are treated as equal. | |
* <p> | |
* Example 1: | |
* Input: "№123" | |
* Output: "No123" | |
* <p> | |
* Example 2: | |
* Input: "Hello World" | |
* Output: "Hello World" | |
* | |
* @param cs the input string to be normalized | |
* @return the normalized string | |
*/ | |
private CharSequence normalize(final CharSequence cs) { | |
return normalizeSubArchiveName(cs, Normalizer.Form.NFKC); | |
} | |
private CharSequence normalize(final CharSequence cs, final Normalizer.Form form) { | |
return Normalizer.isNormalized(cs, form) ? cs : Normalizer.normalize(cs, form); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment