有没有哪个高手帮帮忙,谢谢谢谢.....
并且我现在可以得到文件的byte[]数组..但是我直接输出byte[0],byte[1]这样好象是不行的饿。..
10 个解决方案
#1
在线等,急用,各位大下帮忙
#2
有没有人啊
#3
byte [] buff = item.get();//把字符变成byte
if (buff[0]==-17 && buff[1]==-69 && buff[2]==-65){
this.str = new String(buff,"utf-8");//utf-8
}else if(buff[0]==-1 && buff[1]==-2){
this.str = new String(buff,"unicode");//unicode
}else if(buff[0]==-2 && buff[1]==-1){
this.str = new String(buff,"unicode big endian");//unicode big endian
}else{
this.str = new String(buff,"big5");
}
if (buff[0]==-17 && buff[1]==-69 && buff[2]==-65){
this.str = new String(buff,"utf-8");//utf-8
}else if(buff[0]==-1 && buff[1]==-2){
this.str = new String(buff,"unicode");//unicode
}else if(buff[0]==-2 && buff[1]==-1){
this.str = new String(buff,"unicode big endian");//unicode big endian
}else{
this.str = new String(buff,"big5");
}
#4
用头二个字节来判断
#5
http://topic.csdn.net/u/20080402/11/7ab3a3f3-1019-4c0a-ac99-35388f064b1e.html
#6
sorry 发错了一个链接
讨论继续
讨论继续
#7
if (b[0] == (byte)0xef && b[1] == (byte)0xbb && b[2] == (byte)0xbf)
guess = "UTF-8";
else if (b[0] == (byte)0xff && b[1] == (byte)0xfe)
guess = "UTF-16";
else if (b[0] == (byte)0xfe && b[1] == (byte)0xff && b[2] == (byte)0x00)
guess = "UTF-16BE";
我这样写了
guess = "UTF-8";
else if (b[0] == (byte)0xff && b[1] == (byte)0xfe)
guess = "UTF-16";
else if (b[0] == (byte)0xfe && b[1] == (byte)0xff && b[2] == (byte)0x00)
guess = "UTF-16BE";
我这样写了
#9
TomyGuan
谢谢了/...
谢谢了/...
#10
老紫竹,你给的我没有权限看- -
#1
在线等,急用,各位大下帮忙
#2
有没有人啊
#3
byte [] buff = item.get();//把字符变成byte
if (buff[0]==-17 && buff[1]==-69 && buff[2]==-65){
this.str = new String(buff,"utf-8");//utf-8
}else if(buff[0]==-1 && buff[1]==-2){
this.str = new String(buff,"unicode");//unicode
}else if(buff[0]==-2 && buff[1]==-1){
this.str = new String(buff,"unicode big endian");//unicode big endian
}else{
this.str = new String(buff,"big5");
}
if (buff[0]==-17 && buff[1]==-69 && buff[2]==-65){
this.str = new String(buff,"utf-8");//utf-8
}else if(buff[0]==-1 && buff[1]==-2){
this.str = new String(buff,"unicode");//unicode
}else if(buff[0]==-2 && buff[1]==-1){
this.str = new String(buff,"unicode big endian");//unicode big endian
}else{
this.str = new String(buff,"big5");
}
#4
用头二个字节来判断
#5
http://topic.csdn.net/u/20080402/11/7ab3a3f3-1019-4c0a-ac99-35388f064b1e.html
#6
sorry 发错了一个链接
讨论继续
讨论继续
#7
if (b[0] == (byte)0xef && b[1] == (byte)0xbb && b[2] == (byte)0xbf)
guess = "UTF-8";
else if (b[0] == (byte)0xff && b[1] == (byte)0xfe)
guess = "UTF-16";
else if (b[0] == (byte)0xfe && b[1] == (byte)0xff && b[2] == (byte)0x00)
guess = "UTF-16BE";
我这样写了
guess = "UTF-8";
else if (b[0] == (byte)0xff && b[1] == (byte)0xfe)
guess = "UTF-16";
else if (b[0] == (byte)0xfe && b[1] == (byte)0xff && b[2] == (byte)0x00)
guess = "UTF-16BE";
我这样写了
#8
我这里有一段检测编码类型的代码,成功率很高!
http://www.java2000.net/viewthread.jsp?tid=1679
#9
TomyGuan
谢谢了/...
谢谢了/...
#10
老紫竹,你给的我没有权限看- -