Character 类的 lowSurrogate(int codePoint) 方法返回尾随代理代码单元,该单元用于以 UTF-16 编码表示字符。另一方面,如果指定的字符不是增补字符,则返回未指定的字符。
如果方法 isSupplementaryCodePoint (x) 为真,则方法 isLowSurrogate(lowSurrogate(x)) 和方法 toCodePoint(highSurrogate(x), lowSurrogate(x))==x 也为真。
用法
public static char lowSurrogate(int codePoint)
参数
上述方法只需要一个参数:
a.) codePoint 是需要测试的字符。
返回值
lowSurrogate(int codePoint) 方法返回尾随代码单元,该单元用作 UTF-16 编码中的字符表示。
例子1
public class JavaCharacterlowSurrogateExample1 {
public static void main(String[] args) {
// Initialize three codepoints:cp1, cp2 and cp3.
int cp1 = 65;
int cp2 = 152;
int cp3 = 567;
// Find the current surrogate codePoint.
char result1 = Character.lowSurrogate(cp1);
char result2 = Character.lowSurrogate(cp2);
char result3 = Character.lowSurrogate(cp3);
// Print the result.
System.out.println("The current surrogate code unit for the character"+ cp1 +" is:"+ result1);
System.out.println("The current surrogate code unit for the character"+ cp2 +" is:"+ result2);
System.out.println("The current surrogate code unit for the character"+ cp3 +" is:"+ result3);
}
}
输出:
The current surrogate code unit for the character65 is:? The current surrogate code unit for the character152 is:? The current surrogate code unit for the character567 is:?
例子2
public class JavaCharacterlowSurrogateExample2 {
public static void main(String[] args) {
// Initialize three codepoints:cp1, cp2 and cp3
int cp1 = 49;
int cp2 = 121;
int cp3 = 2342;
// Check whether the codepoints are current surrogate code units or not.
char check1 = Character.lowSurrogate(cp1);
char check2 = Character.lowSurrogate(cp2);
char check3 = Character.lowSurrogate(cp3);
// Print the result.
if(check1==3F){
System.out.print("The codepoint \'"+cp1+"\' is not a current surrogate code unit.\n");
}
else{
System.out.print("The codePoint \'"+cp1+"\' is a current surrogate code unit.\n");
}
if(check2==3F){
System.out.print("The codepoint \'"+cp2+"\' is not a current surrogate code unit.\n");
}
else{
System.out.print("The codePoint \'"+cp2+"\' is a current surrogate code unit.\n");
}
if(check3==3F){
System.out.print("The codepoint \'"+cp3+"\' is not a current surrogate code unit.\n");
}
else{
System.out.print("The codePoint \'"+cp3+"\' is a current surrogate code unit.\n");
}
}
}
输出:
The codePoint '49' is a current surrogate code unit. The codePoint '121' is a current surrogate code unit. The codePoint '2342' is a current surrogate code unit.
相关用法
- 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 getType(char ch)用法及代码示例
注:本文由纯净天空筛选整理自 Java Character lowSurrogate() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。