2013-10-04 43 views

回答

0
byte[] isoBytes = new String(curBytes).getBytes("ISO-8859-1"); 

请注意,如果默认编码已经“丢失”一些字符,则无法恢复他们这种方式。

0
String str = new String(currentByteArray); 
byte[] newByteArray = str.getBytes("ISO-8859-1"); 
0

OK,所以你必须转化为使用默认的平台编码(不管它是一个字节数组的字符串。而你要使用ISO-8859-1这个字符串转换为字节数组。

第一步是由此字节数组变换为字符串:

String s = new String(bytes); // default encoding used here 

,然后将其转变回一个字节数组:

byte[] iso88591Bytes = s.getBytes("ISO-8859-1");