Вот мой тестовый код:
Код: Выделить всё
public static void main(String[] args) throws UnsupportedEncodingException {
String a1 = "𡍼";
System.out.println(a1 + ".charAt(0)=" + (a1.charAt(0) + 0));
StringBuffer a = new StringBuffer();
a.append("a=C0000002006人力資源處").append(a1.charAt(0));
PrintStream out = new PrintStream(System.out, true, "UTF-8");
out.println(a);
System.out.println(a.toString());
StringBuffer b = new StringBuffer();
b.append("b=C0000002006人力資源處").append(a1.substring(0,1));
out.println(b);
System.out.println(b.toString());
}
Код: Выделить всё
𡍼.charAt(0)=55364
a=C0000002006人力資源處?
a=C0000002006人力資源處?
b=C0000002006人力資源處?
b=C0000002006人力資源處?
Как это исправить?
Подробнее здесь: https://stackoverflow.com/questions/790 ... -character