getNumericValue:
public static int getNumericValue(char ch)
Returns the Unicode numeric value of the character as a nonnegative integer. If the character does not have a numeric value, then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned.
Parameters:
ch - the character to be converted.
Returns:
the numeric value of the character, as a nonnegative int value; -2 if the character has a numeric value that is not a nonnegative integer; -1 if the character has no numeric value.
//---------------------------------------------------------
我想只有这种方法了
再去查一下中文的 Unicode 的范围
public static int getNumericValue(char ch)
Returns the Unicode numeric value of the character as a nonnegative integer. If the character does not have a numeric value, then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned.
Parameters:
ch - the character to be converted.
Returns:
the numeric value of the character, as a nonnegative int value; -2 if the character has a numeric value that is not a nonnegative integer; -1 if the character has no numeric value.
//---------------------------------------------------------
我想只有这种方法了
再去查一下中文的 Unicode 的范围
解决方案 »
- 如何布局更完美????
- 想用java做一个类似于putty的工具
- 做串口通讯,求javax.comm的windows包,从sun上没有找到windows的
- 我的J2SE杂安装不上请高手指教!
- 一个空类的实例占多少内存?
- 哪位用过用过ORACLE的Jdeveloper开发过项目,谈谈心得?
- 关于一个取网页代码的问题
- 想学Java
- 关于Jbuilder5
- PrintWriter 源码flush()方法 为什么没有其他的操作知识简单的自身调用自身?
- 在JB6的Swing组的jlabel的icon属性中,为什么无法选中已经添加到工程中的.gif图形文件?
- 请问哪儿有比较好的基于java的网站流量统计程序下载?(内容空)
char字符<256的就是英文字母或者符号
以上的就不是字母了,可能是中文和其他字符
public static final String chopString(String string, int length) { String rc=null;
try{
byte[] bs = string.getBytes();
byte[] newBytes = new byte[length];
System.arraycopy(bs,0,newBytes,0,length -1);
rc = new String(newBytes, "GB2312");
}catch(java.io.UnsupportedEncodingException e){
System.out.println(e.getMessage());
}
// throw away the last char
return rc.substring(0,rc.length() -1);
}