RT
解决方案 »
- 红旗Linux下获取字体名称时引发的异常
- 关于实现模态frame问题
- java swing 程序在宽屏和正常屏幕的显示不一样
- 概念问题,期待回音
- 问:接口属于抽象类,抽象类是不能直接产生对象的,所以接口也不能产生对象,可这却例外,是怎么一回事?
- 为什么getTableName()只能得到空格或者空?
- eclipse调试问题
- TextField显示网络传来的中文信息为什么都是些问号(“????”) ?
- 关于JB8的错误
- 用JB7编译生成EXE文件,提示:Exectuable must have a main class,是什么意思
- 网络边接服务器端出错
- 谁有thinking in java 的 中文的最新版?
not maybe need exact
http://www.xlmz.net/forum/viewthread.php?tid=2036
因此,至于哪些是中文标点你可以从下面输出的数据中人工判定。import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;public class Test1 { public static void main(String[] args) {
List<String> list = getAllUnicode("P", "unicodedata.txt");
for(String str : list) {
if(n <= 0x10000) {
System.out.println(str + " " + (char)n);
}
}
}
public static List<String> getAllUnicode(String propertyPrefix, String filename) {
BufferedReader br = null;
List<String> list = new ArrayList<String>();
try {
br = new BufferedReader(new FileReader(filename));
for(String str = null; (str = br.readLine()) != null; ) {
String[] strs = str.split(";");
if(strs[2].startsWith(propertyPrefix)) {
list.add(strs[0]);
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return list;
}
}unicodedata.txt 文件在这里下载:
http://www.unicode.org/Public/UNIDATA/UnicodeData.txt这是所有 Unicode 字符的字符属性描述文件,第一列是 Unicode 码,第二列是字符名称,第三列是字符子属性。
第三列以 P 开头的都是标点符号。一共有 510 个输出,不过有大部分在我们的机器上是无法显示的,并且在上面的代码中还把超过
U+FFFF 的字符都不让输出了,现在的系统平台基本上不支持 U+FFFF 以上的字符,这样就少很多。如果你要是中文标点,我想中文应该就是占两个字节的全角标点吧,那这样改一下: public static void main(String[] args) {
List<String> list = getAllUnicode("P", "f:/unicodedata.txt");
int count = 0;
for(String str : list) {
int n = Integer.parseInt(str, 16);
if(n <= 0x10000) {
int len = String.valueOf((char)n).getBytes().length;
if (len > 1) {
System.out.println(str + " " + (char)n);
count++;
}
}
}
System.out.println("Count: " + count);
}总共有 106 个,不知道能否满足要求?
System.out.println(str.charAt(0) > 128 ? "Yes" : "No");用这个是可以的..判断中文..
是字符串包含中文,不是首字符包含中文,你其实是判断ASCII码来判断的,还是有你自己说的问题,什么日文韩文的
请各位看清楚了,资料里面文字只会有中文