📄 character.java
字号:
* A character may be part of a Unicode identifier if and only if * one of the following statements is true: * <ul> * <li> it is a letter * <li> it is a connecting punctuation character (such as <code>'_'</code>) * <li> it is a digit * <li> it is a numeric letter (such as a Roman numeral character) * <li> it is a combining mark * <li> it is a non-spacing mark * <li> <code>isIdentifierIgnorable</code> returns * <code>true</code> for this character. * </ul> * * @param ch the character to be tested. * @return <code>true</code> if the character may be part of a * Unicode identifier; <code>false</code> otherwise. * @see java.lang.Character#isIdentifierIgnorable(char) * @see java.lang.Character#isJavaIdentifierPart(char) * @see java.lang.Character#isLetterOrDigit(char) * @see java.lang.Character#isUnicodeIdentifierStart(char) * @since 1.1 */ public static boolean isUnicodeIdentifierPart(char ch) { if (ch <= FAST_PATH_MAX) { return CharacterDataLatin1.isUnicodeIdentifierPart(ch); } else { return CharacterData.isUnicodeIdentifierPart(ch); } } /** * Determines if the specified character should be regarded as * an ignorable character in a Java identifier or a Unicode identifier. * <p> * The following Unicode characters are ignorable in a Java identifier * or a Unicode identifier: * <ul> * <li>ISO control characters that are not whitespace * <ul> * <li><code>'\u0000'</code> through <code>'\u0008'</code> * <li><code>'\u000E'</code> through <code>'\u001B'</code> * <li><code>'\u007F'</code> through <code>'\u009F'</code> * </ul> * * <li>all characters that have the <code>FORMAT</code> general * category value * </ul> * * @param ch the character to be tested. * @return <code>true</code> if the character is an ignorable control * character that may be part of a Java or Unicode identifier; * <code>false</code> otherwise. * @see java.lang.Character#isJavaIdentifierPart(char) * @see java.lang.Character#isUnicodeIdentifierPart(char) * @since 1.1 */ public static boolean isIdentifierIgnorable(char ch) { if (ch <= FAST_PATH_MAX) { return CharacterDataLatin1.isIdentifierIgnorable(ch); } else { return CharacterData.isIdentifierIgnorable(ch); } } /** * Converts the character argument to lowercase using case * mapping information from the UnicodeData file. * <p> * Note that * <code>Character.isLowerCase(Character.toLowerCase(ch))</code> * does not always return <code>true</code> for some ranges of * characters, particularly those that are symbols or ideographs. * * @param ch the character to be converted. * @return the lowercase equivalent of the character, if any; * otherwise, the character itself. * @see java.lang.Character#isLowerCase(char) * @see java.lang.Character#isUpperCase(char) * @see java.lang.Character#toTitleCase(char) * @see java.lang.Character#toUpperCase(char) */ public static char toLowerCase(char ch) { if (ch <= FAST_PATH_MAX) { return CharacterDataLatin1.toLowerCase(ch); } else { return CharacterData.toLowerCase(ch); } } /** * Converts the character argument to uppercase using case mapping * information from the UnicodeData file. * <p> * Note that * <code>Character.isUpperCase(Character.toUpperCase(ch))</code> * does not always return <code>true</code> for some ranges of * characters, particularly those that are symbols or ideographs. * * @param ch the character to be converted. * @return the uppercase equivalent of the character, if any; * otherwise, the character itself. * @see java.lang.Character#isLowerCase(char) * @see java.lang.Character#isUpperCase(char) * @see java.lang.Character#toLowerCase(char) * @see java.lang.Character#toTitleCase(char) */ public static char toUpperCase(char ch) { if (ch <= FAST_PATH_MAX) { return CharacterDataLatin1.toUpperCase(ch); } else { return CharacterData.toUpperCase(ch); } } /** * Converts the character argument to titlecase using case mapping * information from the UnicodeData file. If a character has no * explicit titlecase mapping and is not itself a titlecase char * according to UnicodeData, then the uppercase mapping is * returned as an equivalent titlecase mapping. If the * <code>char</code> argument is already a titlecase * <code>char</code>, the same <code>char</code> value will be * returned. * <p> * Note that * <code>Character.isTitleCase(Character.toTitleCase(ch))</code> * does not always return <code>true</code> for some ranges of * characters. * * @param ch the character to be converted. * @return the titlecase equivalent of the character, if any; * otherwise, the character itself. * @see java.lang.Character#isTitleCase(char) * @see java.lang.Character#toLowerCase(char) * @see java.lang.Character#toUpperCase(char) * @since 1.0.2 */ public static char toTitleCase(char ch) { if (ch <= FAST_PATH_MAX) { return CharacterDataLatin1.toTitleCase(ch); } else { return CharacterData.toTitleCase(ch); } } /** * Returns the numeric value of the character <code>ch</code> in the * specified radix. * <p> * If the radix is not in the range <code>MIN_RADIX</code> <= * <code>radix</code> <= <code>MAX_RADIX</code> or if the * value of <code>ch</code> is not a valid digit in the specified * radix, <code>-1</code> is returned. A character is a valid digit * if at least one of the following is true: * <ul> * <li>The method <code>isDigit</code> is <code>true</code> of the character * and the Unicode decimal digit value of the character (or its * single-character decomposition) is less than the specified radix. * In this case the decimal digit value is returned. * <li>The character is one of the uppercase Latin letters * <code>'A'</code> through <code>'Z'</code> and its code is less than * <code>radix + 'A' - 10</code>. * In this case, <code>ch - 'A' + 10</code> * is returned. * <li>The character is one of the lowercase Latin letters * <code>'a'</code> through <code>'z'</code> and its code is less than * <code>radix + 'a' - 10</code>. * In this case, <code>ch - 'a' + 10</code> * is returned. * </ul> * * @param ch the character to be converted. * @param radix the radix. * @return the numeric value represented by the character in the * specified radix. * @see java.lang.Character#forDigit(int, int) * @see java.lang.Character#isDigit(char) */ public static int digit(char ch, int radix) { if (ch <= FAST_PATH_MAX) { return CharacterDataLatin1.digit(ch, radix); } else { return CharacterData.digit(ch, radix); } } /** * Returns the <code>int</code> value that the specified Unicode * character represents. For example, the character * <code>'\u216C'</code> (the roman numeral fifty) will return * an int with a value of 50. * <p> * The letters A-Z in their uppercase (<code>'\u0041'</code> through * <code>'\u005A'</code>), lowercase * (<code>'\u0061'</code> through <code>'\u007A'</code>), and * full width variant (<code>'\uFF21'</code> through * <code>'\uFF3A'</code> and <code>'\uFF41'</code> through * <code>'\uFF5A'</code>) forms have numeric values from 10 * through 35. This is independent of the Unicode specification, * which does not assign numeric values to these <code>char</code> * values. * <p> * If the character does not have a numeric value, then -1 is returned. * If the character has a numeric value that cannot be represented as a * nonnegative integer (for example, a fractional value), then -2 * is returned. * * @param ch the character to be converted. * @return the numeric value of the character, as a nonnegative <code>int</code> * value; -2 if the character has a numeric value that is not a * nonnegative integer; -1 if the character has no numeric value. * @see java.lang.Character#forDigit(int, int) * @see java.lang.Character#isDigit(char) * @since 1.1 */ public static int getNumericValue(char ch) { if (ch <= FAST_PATH_MAX) { return CharacterDataLatin1.getNumericValue(ch); } else { return CharacterData.getNumericValue(ch); } } /** * Determines if the specified character is ISO-LATIN-1 white space. * This method returns <code>true</code> for the following five * characters only: * <table> * <tr><td><code>'\t'</code></td> <td><code>'\u0009'</code></td> * <td><code>HORIZONTAL TABULATION</code></td></tr> * <tr><td><code>'\n'</code></td> <td><code>'\u000A'</code></td> * <td><code>NEW LINE</code></td></tr> * <tr><td><code>'\f'</code></td> <td><code>'\u000C'</code></td> * <td><code>FORM FEED</code></td></tr> * <tr><td><code>'\r'</code></td> <td><code>'\u000D'</code></td> * <td><code>CARRIAGE RETURN</code></td></tr> * <tr><td><code>' '</code></td> <td><code>'\u0020'</code></td> * <td><code>SPACE</code></td></tr> * </table> * * @param ch the character to be tested. * @return <code>true</code> if the character is ISO-LATIN-1 white * space; <code>false</code> otherwise. * @see java.lang.Character#isSpaceChar(char) * @see java.lang.Character#isWhitespace(char) * deprecated Replaced by isWhitespace(char). *//*** public static boolean isSpace(char ch) {* return (ch <= 0x0020) &&* (((((1L << 0x0009) |* (1L << 0x000A) |* (1L << 0x000C) |* (1L << 0x000D) |* (1L << 0x0020)) >> ch) & 1L) != 0);* }*/ /** * Determines if the specified character is a Unicode space character. * A character is considered to be a space character if and only if * it is specified to be a space character by the Unicode standard. This * method returns true if the character's general category type is any of * the following: * <ul> * <li> <code>SPACE_SEPARATOR</code> * <li> <code>LINE_SEPARATOR</code> * <li> <code>PARAGRAPH_SEPARATOR</code> * </ul> * * @param ch the character to be tested. * @return <code>true</code> if the character is a space character; * <code>false</code> otherwise. * @see java.lang.Character#isWhitespace(char) * @since 1.1 */ public static boolean isSpaceChar(char ch) { if (ch <= FAST_PATH_MAX) { return CharacterDataLatin1.isSpaceChar(ch); } else { return CharacterData.isSpaceChar(ch); } } /** * Determines if the specified character is white space according to Java. * A character is a Java whitespace character if and only if it satisfies * one of the following criteria: * <ul> * <li> It is a Unicode space character (<code>SPACE_SEPARATOR</code>, * <code>LINE_SEPARATOR</code>, or <code>PARAGRAPH_SEPARATOR</code>) * but is not also a non-breaking space (<code>'\u00A0'</code>, * <code>'\u2007'</code>, <code>'\u202F'</code>). * <li> It is <code>'\u0009'</code>, HORIZONTAL TABULATION. * <li> It is <code>'\u000A'</code>, LINE FEED. * <li> It is <code>'\u000B'</code>, VERTICAL TABULATION. * <li> It is <code>'\u000C'</code>, FORM FEED. * <li> It is <code>'\u000D'</code>, CARRIAGE RETURN. * <li> It is <code>'\u001C'</code>, FILE SEPARATOR. * <li> It is <code>'\u001D'</code>, GROUP SEPARATOR. * <li> It is <code>'\u001E'</code>, RECORD SEPARATOR. * <li> It is <code>'\u001F'</code>, UNIT SEPARATOR. * </ul> * * @param ch the character to be tested. * @return <code>true</code> if the character is a Java whitespace * character; <code>false</code> otherwise. * @see java.lang.Character#isSpaceChar(char) * @since 1.1 */ public static boolean isWhitespace(char ch) { if (ch <= FAST_PATH_MAX) { return CharacterDataLatin1.isWhitespace(ch); } else { return CharacterData.isWhitespace(ch); } } /** * Determines if the specified character is an ISO control * character. A character is considered to be an ISO control * character if its code is in the range <code>'\u0000'</code> * through <code>'\u001F'</code> or in the range * <code>'\u007F'</code> through <code>'\u009F'</code>. * * @param ch the character to be tested. * @return <code>true</code> if the character is an ISO control character; * <code>false</code> otherwise. * * @see java.lang.Character#isSpaceChar(char) * @see java.lang.Character#isWhitespace(char) * @since 1.1 */ public static boolean isISOControl(char ch) { return (ch <= 0x009F) && ((ch <= 0x001F) || (ch >= 0x007F)); } /** * Returns a value indicating a character's general category. * * @param ch the character to be tested. * @return a value of type <code>int</code> representing the * character's general category. * @see java.lang.Character#COMBINING_SPACING_MARK * @see java.lang.Character#CONNECTOR_PUNCTUATION * @see java.lang.Character#CONTROL * @see java.lang.Character#CURRENCY_SYMBOL * @see java.lang.Character#DASH_PUNCTUATION * @see java.lang.Character#DECIMAL_DIGIT_NUMBER * @see java.lang.Character#ENCLOSING_MARK * @see java.lang.Character#END_PUNCTUATION * @see java.lang.Character#FINAL_QUOTE_PUNCTUATION * @see java.lang.Character#FORMAT * @see java.lang.Character#INITIAL_QUOTE_PUNCTUATION * @see java.lang.Character#LETTER_NUMBER * @see java.lang.Character#LINE_SEPARATOR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -