字符類的 toCodePoint(char high, char low) 方法通常將指定的代理對轉換為其補充的 codePoint 值。上述方法不會驗證給定的代理對。如有必要,調用方必須使用 isSurrogatePair 對其進行驗證。
用法
public static int toCodePoint(char high, char low)
參數
上述方法需要兩個參數:
a.) 高代理代碼點。
b.) 低代理代碼點。
返回值
toCodePoint(char high, char low) 方法從給定的代理對返回補充 codePoint。
例子1
public class JavaCharactertoCodePointExample1 {
public static void main(String[] args) {
// Create two char objects.
char high = '\ud800';
char low = '\udd10';
// Converts the specified surrogate pair into its respective supplementary codePoint
int result = Character.toCodePoint(high, low);
// Print the result
String str= "The result for the above charactetr is given as:"+result;
System.out.println(str);
}
}
輸出:
The result for the above charactetr is given as:65808
例子2
public class JavaCharactertoCodePointExample2 {
public static void main(String[] args) {
// Create four char objects.
char high1 = '\ud900';
char low1 = '\ud120';
char high2 = '\ud560';
char low2 = '\ud320';
// Converts the specified surrogate pair into its respective supplementary codePoint
int result1 = Character.toCodePoint(high1, low1);
int result2 = Character.toCodePoint(high2, low2);
// Print the result.
String str1 = "The result for the above character is given as:"+result1;
String str2 = "The result for the above character is given as:"+result2;
System.out.println(str1);
System.out.println(str2);
}
}
輸出:
The result for the above character is given as:324896 The result for the above character is given as:-624864
相關用法
- Java Character toChars()用法及代碼示例
- Java Character toTitleCase()用法及代碼示例
- Java Character toUpperCase()用法及代碼示例
- Java Character toString()用法及代碼示例
- Java Character toLowerCase()用法及代碼示例
- Java Character isLetter()用法及代碼示例
- Java Character isAlphabetic()用法及代碼示例
- Java Character isValidCodePoint()用法及代碼示例
- Java Character codePointCount()用法及代碼示例
- Java Character isISOControl()用法及代碼示例
- Java Character getType()用法及代碼示例
- Java Character getNumericValue()用法及代碼示例
- Java Character isSpace()用法及代碼示例
- Java Character isMirrored()用法及代碼示例
- Java Character isBmpCodePoint()用法及代碼示例
- Java Character isIdentifierIgnorable()用法及代碼示例
- Java Character isDigit()用法及代碼示例
- Java Character digit()用法及代碼示例
- Java Character compare()用法及代碼示例
- Java Character isLowerCase()用法及代碼示例
注:本文由純淨天空篩選整理自 Java Character toCodePoint() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。