String text = “字符串”;
byte[] b_utf8 = text.getBytes("UTF-8"); //utf-8
byte[] b_iso88591 = text.getBytes("ISO8859-1"); //iso8859-1
byte[] b_gbk = text.getBytes("GBK"); //gbk
string unicode = getUnicode(text);//unicode
public static String getUnicode(String source) {
String result = "";
for (int i = 0; i < source.length(); i++) {
result += "\\u"+Integer.toHexString((int) source.charAt(i));
}
return result;
}
本回答被网友采纳