[英]why Chinese characters are not displayed correctly inside webView when trying to load an html string inside
在Android上使用webView.loadData(String data, String mimeType, String encoding)
在webView
顯示html內容將無法正確顯示漢字。 使用loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl)
對於空值"baseUrl"
和"historyUrl"
將解決這個問題。 有這種行為嗎?
webView.loadData: Does not display the Chinese characters correctly
webView.loadDataWithBaseURL: Displays the Chinese characters correctly`
webView.loadData("html content containing Chinese characters", "text/html", "UTF-8"); //does not work
webView.loadDataWithBaseURL(null, "html content containing Chinese characters", "text/html", "UTF-8", null); //works
看看這里: WebView中的Android漢字
確保網站的內容也為UTF-8,也與您使用的相同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.