在网页中使用UNICODE字符 [英] Using UNICODE characters inweb page

查看:97
本文介绍了在网页中使用UNICODE字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在一个项目中使用HTML报告.该软件支持多国语言.我动态创建HTML文件并在Web浏览器控件中导航该文件.我需要能够在报告中显示UNICODE字符.谁能告诉我如何在同一个文本文件中写入ASCII字符和UNICODE字符?

谢谢您,

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,

推荐答案

它们不是替代品.

ASCII是Unicode的子集,代码点为0.127.只需使用Unicode.确保文件保存在UTF-8中(可以是其他任何UTF;它们都支持完整的Unicode代码点集,但是标准是UTF-8,其他UTF则不切实际).顺便说一下,与其他UTF不同,UTF-8的设计方式是,它以与ASCII编码完全相同的方式呈现带有ASCII子集的字符,具有完全相同的字节(每个字符一个字节),其他代码点则以可变的字节数.

HTML文档具有匹配的http-equiv(在<head>元素下)很重要:
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):
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />



即使没有http-equiv,它也可以工作,但是在某些情况下,如果缺少它会造成一些混乱.一个示例:默认情况下,站点可以使用UTF-8并始终在HTTP标头中声明此编码,但是如果页面另存为本地文件,则本地系统不会知道"该页面.

—SA



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


这篇关于在网页中使用UNICODE字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆