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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。