Android TextView 中的编码 [英] Encoding in Android TextView

查看:35
本文介绍了Android TextView 中的编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Android 新手.
使用 Json Parsing 时,显示文本出现问题(可能是字体原因,我不知道).
这是我的 Json 返回:

I'm new in Android.
When using Json Parsing, I have a problem with display text(maybe cause by font, I don't know).
This is my Json return:

{"Response":[{"Id":829,"Name":"Tiền không đem lại hạnh phúc nhưng...","ShortDescription":"Một tỷ phú tâm sự với bạn,...  

但是当我在 android 中解析 TextView 时,名称"变为:

But when I parse in TextView in android, the "Name" become:

 "Ti�n không đem lại hạnh phúc nhưng..."

此文本为越南语.我该如何解决?

This text is in Vietnamese. How can I fix it?

推荐答案

我修好了.我的问题是 UTF-8 字符集.

I fixed it. My problem is UTF-8 charset.

String name = "";
try {
    name = new String(c.getString("NAME").getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {

    e.printStackTrace();
}

String decodedName = Html.fromHtml(name).toString();

这篇关于Android TextView 中的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆