gpt4 book ai didi

c# - silverlight/wpf 网页浏览器编码

转载 作者:太空宇宙 更新时间:2023-11-03 14:26:16 24 4
gpt4 key购买 nike

我一直在寻找一个 wpf webbrowser 波兰语字符集的解决方案。玩了几个小时后,我找到了解决方案,也许其他人也需要它,所以我分享一下。

private string EncodeUnicode(string strText)
{
string txtUnicode = "";
foreach (char value in strText)
{
txtUnicode += Regex.Replace(Convert.ToString(value), "[ęóąśłżźćńĘÓĄŚŁŻŹŃ]", "&#" + (int.Parse(string.Format("{0:x4}", (int)value), System.Globalization.NumberStyles.HexNumber)).ToString());
}
return txtUnicode;
}

当然,您可以用您的模式替换 ęóąśłżźćńĘÓĄŚŁŻŹŃ。而不仅仅是使用

WebBrowser.NavigateToString(EncodeUnicode(Content));

如果有人有更好的解决方案,请也分享。

最佳答案

尝试添加

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

<head></head> 内你的 html 字符串的标签。

我遇到了同样的问题,您的解决方案对我有效,这个也有效。

关于c# - silverlight/wpf 网页浏览器编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3876017/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com