Java中国語コードの問題
904 ワード
import java.io.UnsupportedEncodingException;
public class t {
/**
* @param args Windows preferences general WorkSpace
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = " ";
byte[] bytes = null;
try {
bytes = str.getBytes("GBK"); //2
System.out.println(bytes.length);
bytes = str.getBytes("UTF-8");//3
System.out.println(bytes.length);
//str = " "
// 1
bytes = str.getBytes("ISO8859_1");
System.out.println(bytes.length);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}