| Method from java.lang.Character Detail: |
public static int charCount(int codePoint) {
return (codePoint >= 0x10000 ? 2 : 1);
}
Calculates the number of {@code char} values required to represent the
specified Unicode code point. This method checks if the {@code codePoint}
is greater than or equal to {@code 0x10000}, in which case {@code 2} is
returned, otherwise {@code 1}. To test if the code point is valid, use
the #isValidCodePoint(int) method. |
public char charValue() {
return value;
}
Gets the primitive value of this character. |
public static int codePointAt(CharSequence seq,
int index) {
if (seq == null) {
throw new NullPointerException();
}
int len = seq.length();
if (index < 0 || index >= len) {
throw new IndexOutOfBoundsException();
}
char high = seq.charAt(index++);
if (index >= len) {
return high;
}
char low = seq.charAt(index);
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
}
return high;
}
Returns the code point at {@code index} in the specified sequence of
character units. If the unit at {@code index} is a high-surrogate unit,
{@code index + 1} is less than the length of the sequence and the unit at
{@code index + 1} is a low-surrogate unit, then the supplementary code
point represented by the pair is returned; otherwise the {@code char}
value at {@code index} is returned. |
public static int codePointAt(char[] seq,
int index) {
if (seq == null) {
throw new NullPointerException();
}
int len = seq.length;
if (index < 0 || index >= len) {
throw new IndexOutOfBoundsException();
}
char high = seq[index++];
if (index >= len) {
return high;
}
char low = seq[index];
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
}
return high;
}
Returns the code point at {@code index} in the specified array of
character units. If the unit at {@code index} is a high-surrogate unit,
{@code index + 1} is less than the length of the array and the unit at
{@code index + 1} is a low-surrogate unit, then the supplementary code
point represented by the pair is returned; otherwise the {@code char}
value at {@code index} is returned. |
public static int codePointAt(char[] seq,
int index,
int limit) {
if (index < 0 || index >= limit || limit < 0 || limit > seq.length) {
throw new IndexOutOfBoundsException();
}
char high = seq[index++];
if (index >= limit) {
return high;
}
char low = seq[index];
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
}
return high;
}
Returns the code point at {@code index} in the specified array of
character units, where {@code index} has to be less than {@code limit}.
If the unit at {@code index} is a high-surrogate unit, {@code index + 1}
is less than {@code limit} and the unit at {@code index + 1} is a
low-surrogate unit, then the supplementary code point represented by the
pair is returned; otherwise the {@code char} value at {@code index} is
returned. |
public static int codePointBefore(CharSequence seq,
int index) {
if (seq == null) {
throw new NullPointerException();
}
int len = seq.length();
if (index < 1 || index > len) {
throw new IndexOutOfBoundsException();
}
char low = seq.charAt(--index);
if (--index < 0) {
return low;
}
char high = seq.charAt(index);
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
}
return low;
}
Returns the code point that preceds {@code index} in the specified
sequence of character units. If the unit at {@code index - 1} is a
low-surrogate unit, {@code index - 2} is not negative and the unit at
{@code index - 2} is a high-surrogate unit, then the supplementary code
point represented by the pair is returned; otherwise the {@code char}
value at {@code index - 1} is returned. |
public static int codePointBefore(char[] seq,
int index) {
if (seq == null) {
throw new NullPointerException();
}
int len = seq.length;
if (index < 1 || index > len) {
throw new IndexOutOfBoundsException();
}
char low = seq[--index];
if (--index < 0) {
return low;
}
char high = seq[index];
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
}
return low;
}
Returns the code point that preceds {@code index} in the specified
array of character units. If the unit at {@code index - 1} is a
low-surrogate unit, {@code index - 2} is not negative and the unit at
{@code index - 2} is a high-surrogate unit, then the supplementary code
point represented by the pair is returned; otherwise the {@code char}
value at {@code index - 1} is returned. |
public static int codePointBefore(char[] seq,
int index,
int start) {
if (seq == null) {
throw new NullPointerException();
}
int len = seq.length;
if (index < = start || index > len || start < 0 || start >= len) {
throw new IndexOutOfBoundsException();
}
char low = seq[--index];
if (--index < start) {
return low;
}
char high = seq[index];
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
}
return low;
}
Returns the code point that preceds the {@code index} in the specified
array of character units and is not less than {@code start}. If the unit
at {@code index - 1} is a low-surrogate unit, {@code index - 2} is not
less than {@code start} and the unit at {@code index - 2} is a
high-surrogate unit, then the supplementary code point represented by the
pair is returned; otherwise the {@code char} value at {@code index - 1}
is returned. |
public static int codePointCount(CharSequence seq,
int beginIndex,
int endIndex) {
if (seq == null) {
throw new NullPointerException();
}
int len = seq.length();
if (beginIndex < 0 || endIndex > len || beginIndex > endIndex) {
throw new IndexOutOfBoundsException();
}
int result = 0;
for (int i = beginIndex; i < endIndex; i++) {
char c = seq.charAt(i);
if (isHighSurrogate(c)) {
if (++i < endIndex) {
c = seq.charAt(i);
if (!isLowSurrogate(c)) {
result++;
}
}
}
result++;
}
return result;
}
Counts the number of Unicode code points in the subsequence of the
specified character sequence, as delineated by {@code beginIndex} and
{@code endIndex}. Any surrogate values with missing pair values will be
counted as one code point. |
public static int codePointCount(char[] seq,
int offset,
int count) {
if (seq == null) {
throw new NullPointerException();
}
int len = seq.length;
int endIndex = offset + count;
if (offset < 0 || count < 0 || endIndex > len) {
throw new IndexOutOfBoundsException();
}
int result = 0;
for (int i = offset; i < endIndex; i++) {
char c = seq[i];
if (isHighSurrogate(c)) {
if (++i < endIndex) {
c = seq[i];
if (!isLowSurrogate(c)) {
result++;
}
}
}
result++;
}
return result;
}
Counts the number of Unicode code points in the subsequence of the
specified char array, as delineated by {@code offset} and {@code count}.
Any surrogate values with missing pair values will be counted as one code
point. |
public int compareTo(Character c) {
return value - c.value;
}
Compares this object to the specified character object to determine their
relative order. |
public static int digit(char c,
int radix) {
if (radix >= MIN_RADIX && radix < = MAX_RADIX) {
if (c < 128) {
// Optimized for ASCII
int result = -1;
if ('0' < = c && c < = '9') {
result = c - '0';
} else if ('a' < = c && c < = 'z') {
result = c - ('a' - 10);
} else if ('A' < = c && c < = 'Z') {
result = c - ('A' - 10);
}
return result < radix ? result : -1;
}
int result = BinarySearch.binarySearchRange(digitKeys, c);
if (result >= 0 && c < = digitValues[result * 2]) {
int value = (char) (c - digitValues[result * 2 + 1]);
if (value >= radix) {
return -1;
}
return value;
}
}
return -1;
}
Convenience method to determine the value of the specified character
{@code c} in the supplied radix. The value of {@code radix} must be
between MIN_RADIX and MAX_RADIX. |
public static int digit(int codePoint,
int radix) {
return UCharacter.digit(codePoint, radix);
}
Convenience method to determine the value of the character
{@code codePoint} in the supplied radix. The value of {@code radix} must
be between MIN_RADIX and MAX_RADIX. |
public boolean equals(Object object) {
return (object instanceof Character)
&& (value == ((Character) object).value);
}
Compares this object with the specified object and indicates if they are
equal. In order to be equal, {@code object} must be an instance of
{@code Character} and have the same char value as this object. |
public static char forDigit(int digit,
int radix) {
if (MIN_RADIX < = radix && radix < = MAX_RADIX) {
if (0 < = digit && digit < radix) {
return (char) (digit < 10 ? digit + '0' : digit + 'a' - 10);
}
}
return 0;
}
Returns the character which represents the specified digit in the
specified radix. The {@code radix} must be between {@code MIN_RADIX} and
{@code MAX_RADIX} inclusive; {@code digit} must not be negative and
smaller than {@code radix}. If any of these conditions does not hold, 0
is returned. |
public static byte getDirectionality(char c) {
int result = BinarySearch.binarySearchRange(bidiKeys, c);
int high = bidiValues[result * 2];
if (c < = high) {
int code = bidiValues[result * 2 + 1];
if (code < 0x100) {
return (byte) (code - 1);
}
return (byte) (((c & 1) == 1 ? code > > 8 : code & 0xff) - 1);
}
return DIRECTIONALITY_UNDEFINED;
}
Gets the Unicode directionality of the specified character. |
public static byte getDirectionality(int codePoint) {
if (getType(codePoint) == Character.UNASSIGNED) {
return Character.DIRECTIONALITY_UNDEFINED;
}
byte UCDirectionality = UCharacter.getDirectionality(codePoint);
if (UCDirectionality == -1) {
return -1;
}
return DIRECTIONALITY[UCDirectionality];
}
Gets the Unicode directionality of the specified character. |
public static int getNumericValue(char c) {
if (c < 128) {
// Optimized for ASCII
if (c >= '0' && c < = '9') {
return c - '0';
}
if (c >= 'a' && c < = 'z') {
return c - ('a' - 10);
}
if (c >= 'A' && c < = 'Z') {
return c - ('A' - 10);
}
return -1;
}
int result = BinarySearch.binarySearchRange(numericKeys, c);
if (result >= 0 && c < = numericValues[result * 2]) {
char difference = numericValues[result * 2 + 1];
if (difference == 0) {
return -2;
}
// Value is always positive, must be negative value
if (difference > c) {
return c - (short) difference;
}
return c - difference;
}
return -1;
}
Gets the numeric value of the specified Unicode character. |
public static int getNumericValue(int codePoint) {
return UCharacter.getNumericValue(codePoint);
}
Gets the numeric value of the specified Unicode code point. For example,
the code point '\u216B' stands for the Roman number XII, which has the
numeric value 12. |
public static int getType(char c) {
if(c < 1000) {
return typeValuesCache[(int)c];
}
int result = BinarySearch.binarySearchRange(typeKeys, c);
int high = typeValues[result * 2];
if (c < = high) {
int code = typeValues[result * 2 + 1];
if (code < 0x100) {
return code;
}
return (c & 1) == 1 ? code > > 8 : code & 0xff;
}
return UNASSIGNED;
}
Gets the general Unicode category of the specified character. |
public static int getType(int codePoint) {
if (codePoint < 1000 && codePoint > 0) {
return typeValuesCache[codePoint];
}
int type = UCharacter.getType(codePoint);
// the type values returned by UCharacter are not compatible with what
// the spec says.RI's Character type values skip the value 17.
if (type < = Character.FORMAT) {
return type;
}
return (type + 1);
}
Gets the general Unicode category of the specified code point. |
public int hashCode() {
return value;
}
|
public static boolean isDefined(char c) {
return getType(c) != UNASSIGNED;
}
Indicates whether the specified character is defined in the Unicode
specification. |
public static boolean isDefined(int codePoint) {
return UCharacter.isDefined(codePoint);
}
Indicates whether the specified code point is defined in the Unicode
specification. |
public static boolean isDigit(char c) {
// Optimized case for ASCII
if ('0' < = c && c < = '9') {
return true;
}
if (c < 1632) {
return false;
}
return getType(c) == DECIMAL_DIGIT_NUMBER;
}
Indicates whether the specified character is a digit. |
public static boolean isDigit(int codePoint) {
return UCharacter.isDigit(codePoint);
}
Indicates whether the specified code point is a digit. |
public static boolean isHighSurrogate(char ch) {
return (MIN_HIGH_SURROGATE < = ch && MAX_HIGH_SURROGATE >= ch);
}
Indicates whether {@code ch} is a high- (or leading-) surrogate code unit
that is used for representing supplementary characters in UTF-16
encoding. |
public static boolean isISOControl(char c) {
return isISOControl((int)c);
}
Indicates whether the specified character is an ISO control character. |
public static boolean isISOControl(int c) {
return (c >= 0 && c < = 0x1f) || (c >= 0x7f && c < = 0x9f);
}
Indicates whether the specified code point is an ISO control character. |
public static boolean isIdentifierIgnorable(char c) {
return (c >= 0 && c < = 8) || (c >= 0xe && c < = 0x1b)
|| (c >= 0x7f && c < = 0x9f) || getType(c) == FORMAT;
}
Indicates whether the specified character is ignorable in a Java or
Unicode identifier. |
public static boolean isIdentifierIgnorable(int codePoint) {
return UCharacter.isIdentifierIgnorable(codePoint);
}
Indicates whether the specified code point is ignorable in a Java or
Unicode identifier. |
public static boolean isJavaIdentifierPart(char c) {
// Optimized case for ASCII
if (c < 128) {
return (typeTags[c] & ISJAVAPART) != 0;
}
int type = getType(c);
return (type >= UPPERCASE_LETTER && type < = OTHER_LETTER)
|| type == CURRENCY_SYMBOL || type == CONNECTOR_PUNCTUATION
|| (type >= DECIMAL_DIGIT_NUMBER && type < = LETTER_NUMBER)
|| type == NON_SPACING_MARK || type == COMBINING_SPACING_MARK
|| (c >= 0x80 && c < = 0x9f) || type == FORMAT;
}
Indicates whether the specified character is a valid part of a Java
identifier other than the first character. |
public static boolean isJavaIdentifierPart(int codePoint) {
int type = getType(codePoint);
return (type >= UPPERCASE_LETTER && type < = OTHER_LETTER)
|| type == CURRENCY_SYMBOL || type == CONNECTOR_PUNCTUATION
|| (type >= DECIMAL_DIGIT_NUMBER && type < = LETTER_NUMBER)
|| type == COMBINING_SPACING_MARK || type == NON_SPACING_MARK
|| isIdentifierIgnorable(codePoint);
}
Indicates whether the specified code point is a valid part of a Java
identifier other than the first character. |
public static boolean isJavaIdentifierStart(char c) {
// Optimized case for ASCII
if (c < 128) {
return (typeTags[c] & ISJAVASTART) != 0;
}
int type = getType(c);
return (type >= UPPERCASE_LETTER && type < = OTHER_LETTER)
|| type == CURRENCY_SYMBOL || type == CONNECTOR_PUNCTUATION
|| type == LETTER_NUMBER;
}
Indicates whether the specified character is a valid first character for
a Java identifier. |
public static boolean isJavaIdentifierStart(int codePoint) {
int type = getType(codePoint);
return isLetter(codePoint) || type == CURRENCY_SYMBOL
|| type == CONNECTOR_PUNCTUATION || type == LETTER_NUMBER;
}
Indicates whether the specified code point is a valid start for a Java
identifier. |
public static boolean isJavaLetter(char c) {
return isJavaIdentifierStart(c);
} Deprecated! Use - #isJavaIdentifierStart(char)
Indicates whether the specified character is a Java letter. |
public static boolean isJavaLetterOrDigit(char c) {
return isJavaIdentifierPart(c);
} Deprecated! Use - #isJavaIdentifierPart(char)
Indicates whether the specified character is a Java letter or digit
character. |
public static boolean isLetter(char c) {
if (('A' < = c && c < = 'Z') || ('a' < = c && c < = 'z')) {
return true;
}
if (c < 128) {
return false;
}
int type = getType(c);
return type >= UPPERCASE_LETTER && type < = OTHER_LETTER;
}
Indicates whether the specified character is a letter. |
public static boolean isLetter(int codePoint) {
return UCharacter.isLetter(codePoint);
}
Indicates whether the specified code point is a letter. |
public static boolean isLetterOrDigit(char c) {
int type = getType(c);
return (type >= UPPERCASE_LETTER && type < = OTHER_LETTER)
|| type == DECIMAL_DIGIT_NUMBER;
}
Indicates whether the specified character is a letter or a digit. |
public static boolean isLetterOrDigit(int codePoint) {
return UCharacter.isLetterOrDigit(codePoint);
}
Indicates whether the specified code point is a letter or a digit. |
public static boolean isLowSurrogate(char ch) {
return (MIN_LOW_SURROGATE < = ch && MAX_LOW_SURROGATE >= ch);
}
Indicates whether {@code ch} is a low- (or trailing-) surrogate code unit
that is used for representing supplementary characters in UTF-16
encoding. |
public static boolean isLowerCase(char c) {
// Optimized case for ASCII
if ('a' < = c && c < = 'z') {
return true;
}
if (c < 128) {
return false;
}
return getType(c) == LOWERCASE_LETTER;
}
Indicates whether the specified character is a lower case letter. |
public static boolean isLowerCase(int codePoint) {
return UCharacter.isLowerCase(codePoint);
}
Indicates whether the specified code point is a lower case letter. |
public static boolean isMirrored(char c) {
int value = c / 16;
if (value >= mirrored.length) {
return false;
}
int bit = 1 < < (c % 16);
return (mirrored[value] & bit) != 0;
}
Indicates whether the specified character is mirrored. |
public static boolean isMirrored(int codePoint) {
return UCharacter.isMirrored(codePoint);
}
Indicates whether the specified code point is mirrored. |
public static boolean isSpace(char c) {
return c == '\n' || c == '\t' || c == '\f' || c == '\r' || c == ' ';
} Deprecated! Use - #isWhitespace(char)
Indicates whether the specified character is a Java space. |
public static boolean isSpaceChar(char c) {
if (c == 0x20 || c == 0xa0 || c == 0x1680) {
return true;
}
if (c < 0x2000) {
return false;
}
return c < = 0x200b || c == 0x2028 || c == 0x2029 || c == 0x202f
|| c == 0x3000;
}
Indicates whether the specified character is a Unicode space character.
That is, if it is a member of one of the Unicode categories Space
Separator, Line Separator, or Paragraph Separator. |
public static boolean isSpaceChar(int codePoint) {
return UCharacter.isSpaceChar(codePoint);
}
Indicates whether the specified code point is a Unicode space character.
That is, if it is a member of one of the Unicode categories Space
Separator, Line Separator, or Paragraph Separator. |
public static boolean isSupplementaryCodePoint(int codePoint) {
return (MIN_SUPPLEMENTARY_CODE_POINT < = codePoint && MAX_CODE_POINT >= codePoint);
}
Indicates whether {@code codePoint} is within the supplementary code
point range. |
public static boolean isSurrogatePair(char high,
char low) {
return (isHighSurrogate(high) && isLowSurrogate(low));
}
Indicates whether the specified character pair is a valid surrogate pair. |
public static boolean isTitleCase(char c) {
if (c == '\u01c5' || c == '\u01c8' || c == '\u01cb' || c == '\u01f2') {
return true;
}
if (c >= '\u1f88' && c < = '\u1ffc') {
// 0x1f88 - 0x1f8f, 0x1f98 - 0x1f9f, 0x1fa8 - 0x1faf
if (c > '\u1faf') {
return c == '\u1fbc' || c == '\u1fcc' || c == '\u1ffc';
}
int last = c & 0xf;
return last >= 8 && last < = 0xf;
}
return false;
}
Indicates whether the specified character is a titlecase character. |
public static boolean isTitleCase(int codePoint) {
return UCharacter.isTitleCase(codePoint);
}
Indicates whether the specified code point is a titlecase character. |
public static boolean isUnicodeIdentifierPart(char c) {
int type = getType(c);
return (type >= UPPERCASE_LETTER && type < = OTHER_LETTER)
|| type == CONNECTOR_PUNCTUATION
|| (type >= DECIMAL_DIGIT_NUMBER && type < = LETTER_NUMBER)
|| type == NON_SPACING_MARK || type == COMBINING_SPACING_MARK
|| isIdentifierIgnorable(c);
}
Indicates whether the specified character is valid as part of a Unicode
identifier other than the first character. |
public static boolean isUnicodeIdentifierPart(int codePoint) {
return UCharacter.isUnicodeIdentifierPart(codePoint);
}
Indicates whether the specified code point is valid as part of a Unicode
identifier other than the first character. |
public static boolean isUnicodeIdentifierStart(char c) {
int type = getType(c);
return (type >= UPPERCASE_LETTER && type < = OTHER_LETTER)
|| type == LETTER_NUMBER;
}
Indicates whether the specified character is a valid initial character
for a Unicode identifier. |
public static boolean isUnicodeIdentifierStart(int codePoint) {
return UCharacter.isUnicodeIdentifierStart(codePoint);
}
Indicates whether the specified code point is a valid initial character
for a Unicode identifier. |
public static boolean isUpperCase(char c) {
// Optimized case for ASCII
if ('A' < = c && c < = 'Z') {
return true;
}
if (c < 128) {
return false;
}
return getType(c) == UPPERCASE_LETTER;
}
Indicates whether the specified character is an upper case letter. |
public static boolean isUpperCase(int codePoint) {
return UCharacter.isUpperCase(codePoint);
}
Indicates whether the specified code point is an upper case letter. |
public static boolean isValidCodePoint(int codePoint) {
return (MIN_CODE_POINT < = codePoint && MAX_CODE_POINT >= codePoint);
}
Indicates whether {@code codePoint} is a valid Unicode code point. |
public static boolean isWhitespace(char c) {
// Optimized case for ASCII
if ((c >= 0x1c && c < = 0x20) || (c >= 0x9 && c < = 0xd)) {
return true;
}
if (c == 0x1680) {
return true;
}
if (c < 0x2000 || c == 0x2007) {
return false;
}
return c < = 0x200b || c == 0x2028 || c == 0x2029 || c == 0x3000;
}
Indicates whether the specified character is a whitespace character in
Java. |
public static boolean isWhitespace(int codePoint) {
//FIXME depends on ICU when the codePoint is '\u2007'
return UCharacter.isWhitespace(codePoint);
}
Indicates whether the specified code point is a whitespace character in
Java. |
public static int offsetByCodePoints(CharSequence seq,
int index,
int codePointOffset) {
if (seq == null) {
throw new NullPointerException();
}
int len = seq.length();
if (index < 0 || index > len) {
throw new IndexOutOfBoundsException();
}
if (codePointOffset == 0) {
return index;
}
if (codePointOffset > 0) {
int codePoints = codePointOffset;
int i = index;
while (codePoints > 0) {
codePoints--;
if (i >= len) {
throw new IndexOutOfBoundsException();
}
if (isHighSurrogate(seq.charAt(i))) {
int next = i + 1;
if (next < len && isLowSurrogate(seq.charAt(next))) {
i++;
}
}
i++;
}
return i;
}
assert codePointOffset < 0;
int codePoints = -codePointOffset;
int i = index;
while (codePoints > 0) {
codePoints--;
i--;
if (i < 0) {
throw new IndexOutOfBoundsException();
}
if (isLowSurrogate(seq.charAt(i))) {
int prev = i - 1;
if (prev >= 0 && isHighSurrogate(seq.charAt(prev))) {
i--;
}
}
}
return i;
}
Determines the index in the specified character sequence that is offset
{@code codePointOffset} code points from {@code index}. |
public static int offsetByCodePoints(char[] seq,
int start,
int count,
int index,
int codePointOffset) {
if (seq == null) {
throw new NullPointerException();
}
int end = start + count;
if (start < 0 || count < 0 || end > seq.length || index < start
|| index > end) {
throw new IndexOutOfBoundsException();
}
if (codePointOffset == 0) {
return index;
}
if (codePointOffset > 0) {
int codePoints = codePointOffset;
int i = index;
while (codePoints > 0) {
codePoints--;
if (i >= end) {
throw new IndexOutOfBoundsException();
}
if (isHighSurrogate(seq[i])) {
int next = i + 1;
if (next < end && isLowSurrogate(seq[next])) {
i++;
}
}
i++;
}
return i;
}
assert codePointOffset < 0;
int codePoints = -codePointOffset;
int i = index;
while (codePoints > 0) {
codePoints--;
i--;
if (i < start) {
throw new IndexOutOfBoundsException();
}
if (isLowSurrogate(seq[i])) {
int prev = i - 1;
if (prev >= start && isHighSurrogate(seq[prev])) {
i--;
}
}
}
return i;
}
Determines the index in a subsequence of the specified character array
that is offset {@code codePointOffset} code points from {@code index}.
The subsequence is delineated by {@code start} and {@code count}. |
public static char reverseBytes(char c) {
return (char)((c< < 8) | (c > >8));
}
Reverses the order of the first and second byte in the specified
character. |
public static char[] toChars(int codePoint) {
if (!isValidCodePoint(codePoint)) {
throw new IllegalArgumentException();
}
if (isSupplementaryCodePoint(codePoint)) {
int cpPrime = codePoint - 0x10000;
int high = 0xD800 | ((cpPrime > > 10) & 0x3FF);
int low = 0xDC00 | (cpPrime & 0x3FF);
return new char[] { (char) high, (char) low };
}
return new char[] { (char) codePoint };
}
Converts the specified Unicode code point into a UTF-16 encoded sequence
and returns it as a char array. |
public static int toChars(int codePoint,
char[] dst,
int dstIndex) {
if (!isValidCodePoint(codePoint)) {
throw new IllegalArgumentException();
}
if (dst == null) {
throw new NullPointerException();
}
if (dstIndex < 0 || dstIndex >= dst.length) {
throw new IndexOutOfBoundsException();
}
if (isSupplementaryCodePoint(codePoint)) {
if (dstIndex == dst.length - 1) {
throw new IndexOutOfBoundsException();
}
// See RFC 2781, Section 2.1
// http://www.faqs.org/rfcs/rfc2781.html
int cpPrime = codePoint - 0x10000;
int high = 0xD800 | ((cpPrime > > 10) & 0x3FF);
int low = 0xDC00 | (cpPrime & 0x3FF);
dst[dstIndex] = (char) high;
dst[dstIndex + 1] = (char) low;
return 2;
}
dst[dstIndex] = (char) codePoint;
return 1;
}
Converts the specified Unicode code point into a UTF-16 encoded sequence
and copies the value(s) into the char array {@code dst}, starting at
index {@code dstIndex}. |
public static int toCodePoint(char high,
char low) {
// See RFC 2781, Section 2.2
// http://www.faqs.org/rfcs/rfc2781.html
int h = (high & 0x3FF) < < 10;
int l = low & 0x3FF;
return (h | l) + 0x10000;
}
Converts a surrogate pair into a Unicode code point. This method assumes
that the pair are valid surrogates. If the pair are not valid
surrogates, then the result is indeterminate. The
#isSurrogatePair(char, char) method should be used prior to this
method to validate the pair. |
public static char toLowerCase(char c) {
// Optimized case for ASCII
if ('A' < = c && c < = 'Z') {
return (char) (c + ('a' - 'A'));
}
if (c < 192) {// || c == 215 || (c > 222 && c < 256)) {
return c;
}
if (c< 1000) {
return (char)lowercaseValuesCache[c-192];
}
int result = BinarySearch.binarySearchRange(lowercaseKeys, c);
if (result >= 0) {
boolean by2 = false;
char start = lowercaseKeys.charAt(result);
char end = lowercaseValues[result * 2];
if ((start & 0x8000) != (end & 0x8000)) {
end ^= 0x8000;
by2 = true;
}
if (c < = end) {
if (by2 && (c & 1) != (start & 1)) {
return c;
}
char mapping = lowercaseValues[result * 2 + 1];
return (char) (c + mapping);
}
}
return c;
}
Returns the lower case equivalent for the specified character if the
character is an upper case letter. Otherwise, the specified character is
returned unchanged. |
public static int toLowerCase(int codePoint) {
return UCharacter.toLowerCase(codePoint);
}
Returns the lower case equivalent for the specified code point if it is
an upper case letter. Otherwise, the specified code point is returned
unchanged. |
public String toString() {
return String.valueOf(value);
}
|
public static String toString(char value) {
return String.valueOf(value);
}
Converts the specified character to its string representation. |
public static char toTitleCase(char c) {
if (isTitleCase(c)) {
return c;
}
int result = BinarySearch.binarySearch(titlecaseKeys, c);
if (result >= 0) {
return titlecaseValues[result];
}
return toUpperCase(c);
}
Returns the title case equivalent for the specified character if it
exists. Otherwise, the specified character is returned unchanged. |
public static int toTitleCase(int codePoint) {
return UCharacter.toTitleCase(codePoint);
}
Returns the title case equivalent for the specified code point if it
exists. Otherwise, the specified code point is returned unchanged. |
public static char toUpperCase(char c) {
// Optimized case for ASCII
if ('a' < = c && c < = 'z') {
return (char) (c - ('a' - 'A'));
}
if (c < 181) {
return c;
}
if (c< 1000) {
return (char)uppercaseValuesCache[(int)c-181];
}
int result = BinarySearch.binarySearchRange(uppercaseKeys, c);
if (result >= 0) {
boolean by2 = false;
char start = uppercaseKeys.charAt(result);
char end = uppercaseValues[result * 2];
if ((start & 0x8000) != (end & 0x8000)) {
end ^= 0x8000;
by2 = true;
}
if (c < = end) {
if (by2 && (c & 1) != (start & 1)) {
return c;
}
char mapping = uppercaseValues[result * 2 + 1];
return (char) (c + mapping);
}
}
return c;
}
Returns the upper case equivalent for the specified character if the
character is a lower case letter. Otherwise, the specified character is
returned unchanged. |
public static int toUpperCase(int codePoint) {
return UCharacter.toUpperCase(codePoint);
}
Returns the upper case equivalent for the specified code point if the
code point is a lower case letter. Otherwise, the specified code point is
returned unchanged. |
public static Character valueOf(char c) {
if (c >= CACHE_LEN ) {
return new Character(c);
}
return valueOfCache.CACHE[c];
}
Returns a {@code Character} instance for the {@code char} value passed.
For ASCII/Latin-1 characters (and generally all characters with a Unicode
value up to 512), this method should be used instead of the constructor,
as it maintains a cache of corresponding {@code Character} instances. |