| 目次 |
|---|
|
・指定した文字コードで文字のバイト数を求める ・ソース ・実行結果 |
public class Test {
public static void main(String[] args) throws Exception{
String str = "あ";
System.out.println(str.getBytes("UTF-8").length);
System.out.println(str.getBytes("Shift-JIS").length);
System.out.println(str.getBytes("MS932").length);
System.out.println(str.getBytes("EUC-JP").length);
}
}
3 2 2 2