我不知道这个,但是我在下面做了一个简单的演示。在IE或Edge中查看此页面时,它将正确呈现。我尝试了不同的编码,例如utf-16,Windows-1252,但没有用。在我看来,WebBrowser控件存在问题。有人可以弄清楚吗?// html
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<p><i>اتفاقية</i></p>
<p>اتفاقية</p>
</body>
</html>
//。xaml页面
<Page x:Class="WpfApp1.LayoutTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Background="Yellow"
d:DesignHeight="450" d:DesignWidth="800"
Loaded="Page_Loaded"
Title="LayoutTest">
<WebBrowser x:Name="MyWebBrowser" Margin="20,5,0,5"/>
</Page>
//后面的代码
namespace WpfApp1
{
public partial class LayoutTest : Page
{
public LayoutTest()
{
InitializeComponent();
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
string dirPath = AppDomain.CurrentDomain.BaseDirectory;
string fileName = "ArabicPage.html";
string filename = Path.GetFullPath(Path.Combine(dirPath, fileName));
string content = File.ReadAllText(fileName, Encoding.UTF8);
MyWebBrowser.NavigateToString(content);
}
}
}
//结果(没有标签的结果正确)
//在普通浏览器中(边缘)
更新:
我已经使用UWP Webview测试了它,并且在那里可以正常工作。