Click here to Skip to main content
14,924,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm using HTML reporting in one of my project. The software supports multi-language.I dynamically create HTML file and navigate the file in the web browser control. I need to be able to show UNICODE characters in the report. Can any one tell me how can I write ASCII chars and UNICODE chars in the same text file?

Thank you,
Posted

1 solution

They are not alternatives.

ASCII is a subset of Unicode with code points 0.. 127. Just use Unicode. Make sure the file is saved in UTF-8 (could be any other UTF; they all support full set of Unicode code points, but the standard is UTF-8, other UTFs are impractical). By the way, unlike other UTFs, UTF-8 is designed the way it presents the characters withing ASCII subset exactly in the same way as ASCII encoding, with exact same bytes (and with one byte per character), other code points are encoded with variable number of bytes.

Its important that the HTML document has matching http-equiv (under <head> element):
HTML
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


It can work even without http-equiv, but there are situations where the lack if it can create some confusion. One example: a site can use UTF-8 by default and always claim this encoding in HTTP header, but if the page is saved as a local file, the local system does not "know" about it.

—SA
   
v5
Comments
Shahin Khorshidnia 2-May-12 9:06am
   
+5
   
Thank you, Shahin.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900