0
我想爲Android開發調試emoji圖標問題。我的應用程序從遠程服務器讀取短信。如何在Java中打印unicode字符串?
String test = String.format("%s",unicodeStr);
Log.i("xxx",test);
我希望它打印像「\ u23434" ,但它打印‘’。
所以我的問題是,我怎麼能打印出Unicode字符串,因爲它是?
非常感謝。
我想爲Android開發調試emoji圖標問題。我的應用程序從遠程服務器讀取短信。如何在Java中打印unicode字符串?
String test = String.format("%s",unicodeStr);
Log.i("xxx",test);
我希望它打印像「\ u23434" ,但它打印‘’。
所以我的問題是,我怎麼能打印出Unicode字符串,因爲它是?
非常感謝。
我找到一個anoth呃解決方案來解決現在的問題
for (char curr : str.toCharArray()){
//print out the character or do whatever you wanna have
int code = curr;
Log.i("tag",String.format("%x",code));
}
String s = "\\u23434";
System.out.println(s);
它打印Unicode字符串,因爲它是。
添加另一個backslah到你的字符串,如 「\」 + unicodeStr – reporter
@Squonk Java中的字符串是UTF-16編碼。 –
@zhaocong你需要更清楚你的要求。什麼輸入產生的結果?你爲什麼期待這樣的結果? '「\ u23434」'完全不同於''。應該打印什麼而不是''a「'? –