简体   繁体   English

如何为Win RT WebView强制执行UTF-8编码

[英]How do you force UTF-8 encoding for Win RT WebView

I'm writing a universal app for Windows 8.1 / Windows Phone 8.1 that displays web pages in a Windows.UI.Xaml.Controls.WebView . 我正在为Windows 8.1 / Windows Phone 8.1编写一个通用应用程序,该应用程序可在Windows.UI.Xaml.Controls.WebView中显示网页。 The pages are encoded in UTF-8 but they are being displayed as 8-bit text. 这些页面以UTF-8编码,但是以8位文本显示。

Is there a way to force the Windows.UI.Xaml.Controls.WebView to interpret the page as UTF-8? 有没有一种方法可以强制Windows.UI.Xaml.Controls.WebView将页面解释为UTF-8?

I am loading the pages using NavigateToLocalStreamUri so there are no HTTP headers involved. 我正在使用NavigateToLocalStreamUri加载页面,因此不涉及HTTP标头。

If I load the page in Internet Explorer on the desktop then it also treats it as 8-bit text and forcing the encoding using the view menu causes the page to display correctly. 如果我在桌面上的Internet Explorer中加载页面,则它将也将其视为8位文本,并且使用视图菜单强制进行编码会导致页面正确显示。

The page itself starts 页面本身开始

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>

so I don't know why IE gets it wrong at all 所以我根本不知道为什么IE会把它弄错

Any help appreciated. 任何帮助表示赞赏。

You could try specifying the encoding in a meta tag in the head of the page: 您可以尝试在页面headmeta标签中指定编码:

For HTML 4: 对于HTML 4:

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

For HTML 5: 对于HTML 5:

<meta charset="UTF-8">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM