简体   繁体   中英

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 ?

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-Type in 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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM