Character 类的 highSurrogate(intcodePoint) 方法通常返回给定代理对的当前代理 codePoint,它表示 UTF 编码中的补充字符。如果未指定(或有效)给定字符,则返回未指定的字符。
用法
public static char highSurrogate(int codePoint)
参数
codePoint: 是需要测试的补充字符。
返回值
Character 类的 highSurrogate(intcodePoint) 方法返回当前的代理代码单元,用于指示 UTF-16 编码中的字符。
例子1
public class JavaCharacterhighSurrogateExample1 {
public static void main(String[] args) {
// Initialize the codePoints.
int codepoint1 = 6587;
int codepoint2 = 67324;
// Get the leading surrogate
char result1 = Character.highSurrogate(codepoint1);
char result2 = Character.highSurrogate(codepoint2);
// Print the result.
System.out.println("The leading surrogate for the codePoint "+codepoint1 +" is given as:"+result1);
System.out.println("The leading surrogate for the codePoint "+codepoint2 +" is given as:"+result2);
}
}
输出:
The leading surrogate for the codePoint 6587 is given as:? The leading surrogate for the codePoint 67324 is given as:?
例子2
public class JavaCharacterhighSurrogategetTypeExample2 {
public static void main(String args[])
{
System.out.println("The integer value for the character 2 is given as:");
System.out.println(Character.highSurrogate('2'));
System.out.println("The integer value for the character { is given as:");
System.out.println(Character.highSurrogate('{'));
System.out.println("The integer value for the character * is given as:");
System.out.println(Character.highSurrogate('*'));
System.out.println("The integer value for the character @ is given as:");
System.out.println(Character.highSurrogate('@'));
System.out.println("The integer value for the character $ is given as:");
System.out.println(Character.highSurrogate('$'));
}
输出:
The integer value for the character 2 is given as: ? The integer value for the character { is given as: ? The integer value for the character * is given as: ? The integer value for the character @ is given as: ? The integer value for the character $ is given as: ?
相关用法
- Java Character hashCode()用法及代码示例
- 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 toTitleCase()用法及代码示例
- Java Character isMirrored()用法及代码示例
- Java Character isBmpCodePoint()用法及代码示例
- Java Character toUpperCase()用法及代码示例
- Java Character isIdentifierIgnorable()用法及代码示例
- Java Character isDigit()用法及代码示例
- Java Character digit()用法及代码示例
- Java Character toChars()用法及代码示例
- Java Character compare()用法及代码示例
- Java Character isLowerCase()用法及代码示例
- Java Character isJavaIdentifierPart()用法及代码示例
注:本文由纯净天空筛选整理自 Java Character highSurrogate() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。