格式化unicode字符

时间:2015-09-02 07:26:59

标签: java android unicode string-formatting

我收到以下格式的字符串 -

\"When you\u2019re riding, only the race in which you\u2019re riding is important.\u201D

其中\u2019用于单引号

\"\u201D用于左右双引号。

我想格式化它,使其显示正确 -

"When you're riding, only the race in which you're riding is important."

我该怎么做?

1 个答案:

答案 0 :(得分:2)

试试这个:

try
{
    String s = new String("\"When you\u2019re riding, only the race in which you\u2019re riding is important.\u201D".getBytes(), "UTF-8");
}
catch (UnsupportedEncodingException e)
{
    Log.e("utf8", "conversion", e);
}