java - 格式化 unicode 字符

标签 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."

我怎样才能做到这一点?

最佳答案

试试这个:

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);
}

关于java - 格式化 unicode 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32346998/

相关文章:

android - 为什么 Android 应用程序更新/补丁大小与其安装文件一样?

java - 控制和创建多个 Sprite 数组 Java Libgdx

android - GPS:NTP时间注入(inject)的工作原理

unicode - FreeBSD 设置为 UTF-8,但似乎以 ASCII 显示

java - Hibernate数据库连接配置

java - 导入 java.util.Random 不存在

r - R中的UTF-8文件输出

c++ - 如何将 unicode 点 U+10000 编码为 char16_t 字符串文字?

java - 我尝试在 s40 手机上使用 Nokicert,但是当我在 cmd 中打开它时,出现异常错误

java - 运行 Spring Boot 应用程序的初始内存量