Android-å,ä,ö等字符无法在WebView中正确显示 [英] Android - Characters such as å,ä,ö do not render correctly in WebView
问题描述
我正在使用以下代码在android中呈现我的Web视图-
I am using the following code to render my webview in android -
webview.loadDataWithBaseURL(null, "Subject: "+ getSubject() +" Content: "+ getContent() , "text/html" , "UTF-8", "");
我从服务器接收到的主题和内容是UTF编码的,并在日志和屏幕上错误地显示为Ã、、、、.但是,在iOS Web视图中,它们正确显示为å,ä,ö.如何使它们在android中也显示为å,ä,ö?
The subject and content that I receive from the server are UTF encoded and show wrongly as Ã¥,ä,ö in the log and on screen. However in iOS webview they show up correctly as å,ä,ö. How do I get them to show as å,ä,ö in android as well?
推荐答案
这是由于我如何从服务器检索消息.我正在逐字符读取Http响应字符,因此它破坏了编码.当我开始逐行阅读时,效果很好!
It was due to how I was retrieving the message from the server. I was reading the Http response character by character so it broke up the encoding. When I started reading line by line it worked fine!
这篇关于Android-å,ä,ö等字符无法在WebView中正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!