[英]silverlight/wpf webbrowser encoding
i was looking for a long time to get a solution for polish charset in wpf webbrowser. 我一直在寻找很长时间才能在wpf webbrowser中获得波兰字符集的解决方案。 After few hours of playing i made a solution, maybe someone else will need it also so i share.
在玩了几个小时后,我提出了解决方案,也许其他人也会需要它,所以我分享了。
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;
}
Ofcourse you can replace ęóąśłżźćńĘÓĄŚŁŻŹŃ with your pattern. 当然,您可以用图案替换ęóąśłżźćńżźÓĘ。 And than just use
而不仅仅是使用
WebBrowser.NavigateToString(EncodeUnicode(Content));
If someone got better solution plz share it also. 如果有人得到更好的解决方案,请共享。
Try to add 尝试添加
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'>
within <head></head>
tag of your html string. 在html字符串的
<head></head>
标记内。
I had the same problem, your solution worked for me, and this worked too. 我遇到了同样的问题,您的解决方案对我有用,这也起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.