Character 類的 isISOControl(int codePoint) 方法一般判斷引用的字符是否為 ISO 控製字符。
如果給定字符的代碼在 '\u000' 到 '\u001F' 的範圍內或在 '\u007F' 到 '\u009F' 的範圍內,則可以將字符視為 ISO 控製字符。
用法
public static boolean isISOControl(int codePoint)
參數
codePoint:codePoint 是需要測試的字符。
返回值
如果給定(或指定)字符是 ISO 控製字符,則 isISOControl(int codePoint) 方法返回一個布爾值,即 true。否則,該方法返回 false
例子1
public class JavaCharacterisISOControlExample_1 {
public static void main(String args[]){
// Initialize three codepoints.
int codepoint1 = 28;
int codepoint2 = 13480;
int codepoint3 = 13542;
// Check whether the codepoints are isISOControl character or not.
boolean check1 = Character.isISOControl(codepoint1);
boolean check2 = Character.isISOControl(codepoint2);
boolean check3 = Character.isISOControl(codepoint3);
// Print the result.
System.err.print("The first codepoint \'"+codepoint1+"\' is an ISO Control:"+check1+ "\n");
System.err.print("The second codepoint \'"+codepoint2+"\' is an ISO Control:"+check2+"\n");
System.err.print("The third codepoint \'"+codepoint3+"\' is an ISO Control:"+check3+"\n");
}
}
輸出:
The first codepoint '28' is an ISO Control:true The second codepoint '13480' is an ISO Control:false The third codepoint '13542' is an ISO Control:false
例子2
import java.util.Scanner;
public class JavaCharacterisISOControlExample_2 {
public static void main(String[] args) {
// Ask for user input
System.out.print("Enter the first input:");
// Use the Scanner class to get the user input
Scanner s1 = new Scanner(System.in);
// Gets the user input
char[] value1 = s1.nextLine().toCharArray();
// Check whether the user input is an ISO control character or not
for (char ch1:value1) {
boolean result1 = Character.isISOControl(ch1);
// print the result
if(result1){
System.out.println("The character " + ch1 + " is an ISO control character:");
}
else{
System.out.println("The character " + ch1 + " is not an ISO control character:");
}
System.out.print("Enter the second input:");
Scanner s2 = new Scanner(System.in);
char[] value2 = s2.nextLine().toCharArray();
for (char ch2:value2) {
boolean result2 = Character.isISOControl(ch2);
if(result2){
System.out.println("The character " + ch2 + " is an ISO control character:");
}
else{
System.out.println("The character " + ch2 + " is not an ISO control character:");
}
}
}
}
}
輸出:
Enter the first input:@ The character @ is not an ISO control character: Enter the second input:A The character A is not an ISO control character:
相關用法
- Java Character isIdentifierIgnorable()用法及代碼示例
- Java Character isLetter()用法及代碼示例
- Java Character isAlphabetic()用法及代碼示例
- Java Character isValidCodePoint()用法及代碼示例
- Java Character isSpace()用法及代碼示例
- Java Character isMirrored()用法及代碼示例
- Java Character isBmpCodePoint()用法及代碼示例
- Java Character isDigit()用法及代碼示例
- Java Character isLowerCase()用法及代碼示例
- Java Character isJavaIdentifierPart()用法及代碼示例
- Java Character isUpperCase()用法及代碼示例
- Java Character isLowSurrogate()用法及代碼示例
- Java Character isJavaLetterOrDigit()用法及代碼示例
- Java Character isWhitespace()用法及代碼示例
- Java Character isDefined()用法及代碼示例
- Java Character isJavaIdentifierstart()用法及代碼示例
- Java Character isHighSurrogate()用法及代碼示例
- Java Character isLetterOrDigit()用法及代碼示例
- Java Character isSpaceChar()用法及代碼示例
- Java Character codePointCount()用法及代碼示例
注:本文由純淨天空篩選整理自 Java Character isISOControl() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。