JAVA如何把这个十六进制字符串数组转换成汉字?00 20 00 2000 31 00 30 00 31
00 31 00 39 00 38 00 35 00 30
00 37 00 32 00 37 00 8F里面是性别,名族,日期
00 31 00 39 00 38 00 35 00 30
00 37 00 32 00 37 00 8F里面是性别,名族,日期
解决方案 »
- proguard有没有这样的功能
- 在Hibernate中不能添加一条中文,却能添加一条英文的诡异问题!
- 关于servlet在web.xml文件中的出现的*.do,求指点
- struts2 fckeditor 上传文件问题
- 想问一下Lucene的score问题
- SEVERE: Exception starting filter Set Character Encoding
- 在weblogic9中如何设置默认的服务?知道的告诉下。急。谢~~~
- 如何给servelt传递一些自定义参数
- C++中可实现某个函数的参数可为n个,请问java中这个函数如何定义:TestFunc(String p1,String p2,String p3.... , String pn)?
- 如何获取数据库中2分钟内写入的所有记录呢
- 请教OPC服务器通信问题
- 使用struts2和tomcat的memory leak问题
http://topic.csdn.net/u/20070515/10/dbf0c19b-bce0-4614-aba5-53632938d8ba.html
throws UnsupportedEncodingException构造一个新的 String,方法是使用指定的字符集解码指定的字节数组。新的 String 的长度是一个字符集函数,因此不能等于字节数组的长度。
当给定字节在给定字符集中无效的情况下,该构造方法无指定的行为。当需要进一步控制解码过程时,应使用 CharsetDecoder 类。
参数:
bytes - 要解码为字符的字节
charsetName - 受支持的 charset 的名称
抛出:
UnsupportedEncodingException - 如果指定字符集不受支持
---------------------------------------------------------------
String类的一个构造方法,第二个参数指定你的bytes是什么字符集.
63 99 9F 20 00 20 00 20 00 20
00 20 00 20 00 20 00 20 00 20
00 20 这个是姓名53 6C 51 89 5B 40 5C 20 00 20
00 20 00 20 00 20 00 20 00 20
00 20 00 20 00 32 00 30 00 30
00 38 这个是出来应该是 长泰县公安局 才对
String HX = "BABAD7D6D7AABBBB";
byte[] b = new byte[HX.length()/2];
for(int i=0;i<HX.length();){
int j = Integer.parseInt(HX.substring(i,i+2), 16);
b[i/2]=(byte) j;
i+=2;
}
try {
System.out.println(new String(sb,"GB2312"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
byte[] b = new byte[HX.length()/2];
for(int i=0;i<HX.length();){
int j = Integer.parseInt(HX.substring(i,i+2), 16);
b[i/2]=(byte) j;
i+=2;
}
try {
System.out.println(new String(b,"GB2312"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}