所有重音字符都应该使用 html 实体吗? [英] Should all accented characters use html entities?

查看:46
本文介绍了所有重音字符都应该使用 html 实体吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理大量的 HTML 文件,这些文件大多编码为 utf-8.有很多重音字符,因为很多都是法语.我一直在将它们转换为 HTML 实体,但我注意到即使在 IE5.5(根据 IE 测试人员)中,未转换的重音字符也能正确显示.

I am working with a large number of HTML files that are mostly encoded as utf-8. There are accented characters galore as many are in French. I have been converting them to HTML entities as I go, but I noticed that even in IE5.5 (according IE tester) the nonconverted accented characters are displaying properly.

为了安全起见,我是否应该关注字符显示并将它们全部转换为 HTML 实体?

Should I be concerned with character display and convert them all to HTML entities just to be on the safe side?

推荐答案

如果文件是 UTF-8 编码,您应该将 Content-Type 标头设置为 text/html;charset=UTF-8 并在页面上有一个等效的元标记:

If the files are UTF-8 encoded, you should set the Content-Type header to be text/html; charset=UTF-8 and have an equivalent meta tag on the page:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

这为浏览器提供了正确显示 UTF-8 字符的所有信息.无需对重音字符进行编码.

This gives the browser all the information for displaying UTF-8 characters correctly. There is no need to encode accented characters.

这篇关于所有重音字符都应该使用 html 实体吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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