WebView LoadData garbled problem

Source: Internet
Author: User

Transferred from: http://blog.sina.com.cn/s/blog_5da93c8f0101p4y8.html

The recent project to use WebView load a piece of HTML text, using the WebView loaddata (detail, "text/html", "UTF-8"), the test found that the Chinese garbled, found the answer on Google. Change to LoadData (data, "text/html; Charset=utf-8 ", null); it's not garbled.

The reasons are as follows:
If you use Loaddatawithbaseurl, if you do not pass in the URL, the refresh will cause a white screen, because the refresh is called the Reload method, reload is based on the incoming URL to reload once again Loadurl (URL), do not pass in the URL, The default URL is About:blank

You can use LoadData, refresh is only from the cache, but in more than 4.0, if the API is written in the LoadData (data, "UTF-8", null), the time will be garbled, if written loaddata (data, "text/html; Charset=utf-8 ", null); LoadData The final mechanism is to put the incoming three parameters together, and then Loadurl operation, the parameter is data," text/html; Charset=utf-8 ", null these three are assembled, joined text/html; Charset=utf-8 is equivalent to restricting the character of the page


Today, when testing, found Mwebview.loaddata (detail, "text/html;charset=utf-8", null); In the millet one s still exist in the case of Chinese garbled, changed to Webview.loaddatawithbaseurl (NULL, detail, "text/html", "UTF-8", null); There's no problem. Specific reasons have not been found, if you know the classmate, I hope you can @ me!

WebView LoadData garbled problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.