对的WebView和ICS UTF-8编码 [英] UTF-8 encoding on WebView and ICS

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

问题描述

要正确显示在的WebView ,我通常会使用 DOCTYPE 和<$ C UTF-8文本$ C>元标签:

 &LT; META HTTP-当量=Content-Type的CONTENT =text / html的;字符集= UTF-8/&GT;
 

和我使用的提示,我已经看到了堆栈溢出:

 字符串= URLEn coder.en code(字符串,UTF-8)的replaceAll(\\ +,)。
 

这是正常工作的姜饼及以上的Andr​​oid版本,但我的Nexus S最近收到的冰淇淋三明治更新,而像电子法国字符A è等显示如下:为例。

我不知道,如果ISO-XXXX-1编码的解决方案,但如果有人有同样的问题,欢迎交流。

解决方案

请尝试使用方法loadDataWithBaseURL随机字符串为其他PARAMS而不是loadData

To correctly display UTF-8 text in a WebView, I usually use a doctype and a meta tag :

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

and I use a tip I've seen on Stack Overflow:

string = URLEncoder.encode(string, "UTF-8").replaceAll("\\+", " ");

That works fine on Gingerbread and older Android versions, but my Nexus S recently received the Ice Cream Sandwich update, and French characters like é, à, è, etc. are displayed like this: é, for example.

I don't know if the ISO-xxxx-1 encoding is the solution, but if someone had the same problem, please share.

解决方案

Try using the method loadDataWithBaseURL with random String for the other params instead of loadData

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

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