-3

一部の Unicode 文字 (実際には漢字) を含む文字列があり、元の外観に変換できません。

メソッドは、漢字ではなく、Unicode 文字列をSystem.out.println()出力するだけです。\u....."これは私が使用しているコードです:

String code = "\\" + "u751c";
System.out.println(code);
System.out.println(code.length());

code = "\u751c";
System.out.println(code);
System.out.println(code.length());

結果は次のとおりです。

\u751c 
6
甜
1

どうすれば実際の漢字を取得できますか?

すべてのコメントと回答に感謝します.多分私は自分自身を明確にしませんでした.私が得る文字列は( "\" + "u751c")の形式である可能性があります.System.out.println()の結果は "\u751c"を返すだけです. 「甜」の文字ではありません。

// text_title is the string scraped from other website using Jsoup. 
System.out.println(text_title);
System.out.println("\u53f0\u6e7e\u8fdb\u53e3 Love of office lady \u5c0f\u8d44\u5973\u4e4b\u604b \u8349\u8393\u5de7\u514b\u529b\u674f\u4ec1\u5377\u5fc3\u9165 80g/\u76d2");

コンソールのコンテンツ:

\u53f0\u6e7e\u8fdb\u53e3 Love of office lady \u5c0f\u8d44\u5973\u4e4b\u604b \u8349\u8393\u5de7\u514b\u529b\u674f\u4ec1\u5377\u5fc3\u9165 80g/\u76d2
台湾进口 Love of office lady 小资女之恋 草莓巧克力杏仁卷心酥 80g/盒                                                                                       

文字列 text_title はこの形式 ("\" + "u751c") でエスケープされている可能性がありますが、どうすれば漢字に変換できますか?

4

1 に答える 1