Sandip
Sandip

Reputation: 481

how to display unicode character in web browser control in WPF

I want to display unicode character for different languages in web browser control of WPF but it displays special characters

is there any setting I have to set in web browser control ?

Upvotes: 3

Views: 7645

Answers (2)

noseratio
noseratio

Reputation: 61686

You did not tell us how your load the content into WebBrowser. If you navigate to a URL, make sure the server sends correct charset encoding as part of Content-Typein HTTP response headers:

Content-Type: text/html; charset=utf-8

If you have no control over the server, and the server doesn't specify the charset in the response content (a bad manner), you'd need to manually set the encoding using DOM document.charset property, once the document has been loaded. This property is not exposed by the WPF version of WebBrowser, so you'd need to use dynamic:

dynamic domDocument = webBrowser.Document;
domDocument.charset = "Windows-1252";

I'm using "Windows-1252" as an example here, you'd actually need to experiment to find the correct value for a particular web page, if the server doesn't specify it. Load the page into full IE, go to View/Encoding/More menu and find what works for that page.

That said, if you navigate to a string (with NavigateToString), it should support Unicode characters out-of-the-box.

Upvotes: 1

Rajesh Subramanian
Rajesh Subramanian

Reputation: 6490

You can try changing the header by adding Accept-Language in Navigate method.

http://support.microsoft.com/kb/172998

SO Link

How to set Accept and Accept-Language header fields?

Upvotes: 0

Related Questions