當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Java Character highSurrogate()用法及代碼示例


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