字符类的 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。