自己查一查javadoc 中的String 类
解决方案 »
- bmp图片读取与修改,C中的用结构体读取,java中简单的方法是什么,哪位大哥能帮帮我呢
- 大家看看这个程序请教为什么图片不出来的呢
- 如何在java中模拟执行windows命令提示符下的命令,比如模拟在命令提示符下执行ant
- 关于Java调用外部程序的问题,坐等回答
- 关于2维数组的查找, 时间复杂度
- 在jdk下面调用com出问题拉?劳驾知道的进来一下。
- 基础问题
- 关于ORACLE9中数据导入的问题请教!!!!!!!!!!!
- 在java中au声音暂停怎么做?
- 如何使Frame最大化无效
- 我的applet和socket结合的问题,
- javac编译通过运行时 Exception in thread "main" java.lang.NoClassDefFoundError: SqlService
{
byte[] b = "你".getBytes("unicode");
for(int i=0,iSize=b.length;i<iSize;i++)
System.out.println(Integer.toHexString(b[i]));
}
catch(UnsupportedEncodingException e)
{
}
如果你的字符来源于其他(文件、网络)那么就要在发送时候就指定是那种类型字符,在java再将他转换
难道要自己用native2ascii.exe去转换,然后再打开自己看吗不能写一个程序算出来,整整齐齐的打印在屏幕上面吗?
byte[] b = str.getBytes("UTF-16");
for(int i=0;i<b.length;i++)
System.out.println(Integer.toHexString(b[i]));
看看JavaDoc上怎么说的getNumericValuepublic static int getNumericValue(char ch)
Returns the int value that the specified Unicode character represents. For example, the character '\u216C' (the roman numeral fifty) will return an int with a value of 50. The letters A-Z in their uppercase ('\u0041' through '\u005A'), lowercase ('\u0061' through '\u007A'), and full width variant ('\uFF21' through '\uFF3A' and '\uFF41' through '\uFF5A') forms have numeric values from 10 through 35. This is independent of the Unicode specification, which does not assign numeric values to these char values. 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.
Since:
1.1
See Also:
forDigit(int, int), isDigit(char
char c='中';
System.out.println(Integer.toHexString(c));
你可以反编译class看看对不对
在class里面所有的字符串都被解析成unicode
String的话用str.toCharArray()得到char串
byte[] b = str.getBytes("UTF-16");
for(int i=0;i<b.length;i++)
System.out.println(Integer.toHexString(b[i]));
好像是有些问题的!
Character.getNumericValue();一个函数就搞定了,要得着那么复杂?
...
-----------------------------------
不能用