views:

16

answers:

0

Hi, i was looking for a long time to get a solution for polish charset in 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.