mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8248655: Support supplementary characters in String case insensitive operations
8248434: some newly added locale cannot parse uppercased date string Reviewed-by: jlaskey, joehw, rriggs, bchristi
This commit is contained in:
parent
dc80e63811
commit
1f63603288
7 changed files with 272 additions and 87 deletions
|
@ -43,7 +43,6 @@ import java.util.Optional;
|
|||
import java.util.Spliterator;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -1134,16 +1133,16 @@ public final class String
|
|||
/**
|
||||
* Compares this {@code String} to another {@code String}, ignoring case
|
||||
* considerations. Two strings are considered equal ignoring case if they
|
||||
* are of the same length and corresponding characters in the two strings
|
||||
* are equal ignoring case.
|
||||
* are of the same length and corresponding Unicode code points in the two
|
||||
* strings are equal ignoring case.
|
||||
*
|
||||
* <p> Two characters {@code c1} and {@code c2} are considered the same
|
||||
* <p> Two Unicode code points are considered the same
|
||||
* ignoring case if at least one of the following is true:
|
||||
* <ul>
|
||||
* <li> The two characters are the same (as compared by the
|
||||
* <li> The two Unicode code points are the same (as compared by the
|
||||
* {@code ==} operator)
|
||||
* <li> Calling {@code Character.toLowerCase(Character.toUpperCase(char))}
|
||||
* on each character produces the same result
|
||||
* <li> Calling {@code Character.toLowerCase(Character.toUpperCase(int))}
|
||||
* on each Unicode code point produces the same result
|
||||
* </ul>
|
||||
*
|
||||
* <p>Note that this method does <em>not</em> take locale into account, and
|
||||
|
@ -1158,6 +1157,7 @@ public final class String
|
|||
* false} otherwise
|
||||
*
|
||||
* @see #equals(Object)
|
||||
* @see #codePoints()
|
||||
*/
|
||||
public boolean equalsIgnoreCase(String anotherString) {
|
||||
return (this == anotherString) ? true
|
||||
|
@ -1224,7 +1224,8 @@ public final class String
|
|||
|
||||
/**
|
||||
* A Comparator that orders {@code String} objects as by
|
||||
* {@code compareToIgnoreCase}. This comparator is serializable.
|
||||
* {@link #compareToIgnoreCase(String) compareToIgnoreCase}.
|
||||
* This comparator is serializable.
|
||||
* <p>
|
||||
* Note that this Comparator does <em>not</em> take locale into account,
|
||||
* and will result in an unsatisfactory ordering for certain locales.
|
||||
|
@ -1261,10 +1262,10 @@ public final class String
|
|||
/**
|
||||
* Compares two strings lexicographically, ignoring case
|
||||
* differences. This method returns an integer whose sign is that of
|
||||
* calling {@code compareTo} with normalized versions of the strings
|
||||
* calling {@code compareTo} with case folded versions of the strings
|
||||
* where case differences have been eliminated by calling
|
||||
* {@code Character.toLowerCase(Character.toUpperCase(character))} on
|
||||
* each character.
|
||||
* {@code Character.toLowerCase(Character.toUpperCase(int))} on
|
||||
* each Unicode code point.
|
||||
* <p>
|
||||
* Note that this method does <em>not</em> take locale into account,
|
||||
* and will result in an unsatisfactory ordering for certain locales.
|
||||
|
@ -1275,6 +1276,7 @@ public final class String
|
|||
* specified String is greater than, equal to, or less
|
||||
* than this String, ignoring case considerations.
|
||||
* @see java.text.Collator
|
||||
* @see #codePoints()
|
||||
* @since 1.2
|
||||
*/
|
||||
public int compareToIgnoreCase(String str) {
|
||||
|
@ -1362,30 +1364,26 @@ public final class String
|
|||
* <p>
|
||||
* A substring of this {@code String} object is compared to a substring
|
||||
* of the argument {@code other}. The result is {@code true} if these
|
||||
* substrings represent character sequences that are the same, ignoring
|
||||
* case if and only if {@code ignoreCase} is true. The substring of
|
||||
* this {@code String} object to be compared begins at index
|
||||
* {@code toffset} and has length {@code len}. The substring of
|
||||
* {@code other} to be compared begins at index {@code ooffset} and
|
||||
* has length {@code len}. The result is {@code false} if and only if
|
||||
* at least one of the following is true:
|
||||
* <ul><li>{@code toffset} is negative.
|
||||
* <li>{@code ooffset} is negative.
|
||||
* <li>{@code toffset+len} is greater than the length of this
|
||||
* substrings represent Unicode code point sequences that are the same,
|
||||
* ignoring case if and only if {@code ignoreCase} is true.
|
||||
* The sequences {@code tsequence} and {@code osequence} are compared,
|
||||
* where {@code tsequence} is the sequence produced as if by calling
|
||||
* {@code this.substring(toffset, len).codePoints()} and {@code osequence}
|
||||
* is the sequence produced as if by calling
|
||||
* {@code other.substring(ooffset, len).codePoints()}.
|
||||
* The result is {@code true} if and only if all of the following
|
||||
* are true:
|
||||
* <ul><li>{@code toffset} is non-negative.
|
||||
* <li>{@code ooffset} is non-negative.
|
||||
* <li>{@code toffset+len} is less than or equal to the length of this
|
||||
* {@code String} object.
|
||||
* <li>{@code ooffset+len} is greater than the length of the other
|
||||
* <li>{@code ooffset+len} is less than or equal to the length of the other
|
||||
* argument.
|
||||
* <li>{@code ignoreCase} is {@code false} and there is some nonnegative
|
||||
* integer <i>k</i> less than {@code len} such that:
|
||||
* <blockquote><pre>
|
||||
* this.charAt(toffset+k) != other.charAt(ooffset+k)
|
||||
* </pre></blockquote>
|
||||
* <li>{@code ignoreCase} is {@code true} and there is some nonnegative
|
||||
* integer <i>k</i> less than {@code len} such that:
|
||||
* <blockquote><pre>
|
||||
* Character.toLowerCase(Character.toUpperCase(this.charAt(toffset+k))) !=
|
||||
* Character.toLowerCase(Character.toUpperCase(other.charAt(ooffset+k)))
|
||||
* </pre></blockquote>
|
||||
* <li>if {@code ignoreCase} is {@code false}, all pairs of corresponding Unicode
|
||||
* code points are equal integer values; or if {@code ignoreCase} is {@code true},
|
||||
* {@link Character#toLowerCase(int) Character.toLowerCase(}
|
||||
* {@link Character#toUpperCase(int)}{@code )} on all pairs of Unicode code points
|
||||
* results in equal integer values.
|
||||
* </ul>
|
||||
*
|
||||
* <p>Note that this method does <em>not</em> take locale into account,
|
||||
|
@ -1400,12 +1398,14 @@ public final class String
|
|||
* @param other the string argument.
|
||||
* @param ooffset the starting offset of the subregion in the string
|
||||
* argument.
|
||||
* @param len the number of characters to compare.
|
||||
* @param len the number of characters (Unicode code units -
|
||||
* 16bit {@code char} value) to compare.
|
||||
* @return {@code true} if the specified subregion of this string
|
||||
* matches the specified subregion of the string argument;
|
||||
* {@code false} otherwise. Whether the matching is exact
|
||||
* or case insensitive depends on the {@code ignoreCase}
|
||||
* argument.
|
||||
* @see #codePoints()
|
||||
*/
|
||||
public boolean regionMatches(boolean ignoreCase, int toffset,
|
||||
String other, int ooffset, int len) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue