public class Test {
public static void main(String args[]) {
String str = "Test 中文";
for (int i = 0; i < str.length(); i++) {
int c = (int) str.charAt(i);
if (c >= 19968 && c < 40623) {// 中文
// TO DO
System.out.println("第"+(i+1)+"个字符是中文");
}
}
}
}
Java中判断字符为中文的方法
最新推荐文章于 2021-02-16 12:33:52 发布