如何在 HTML 页面中显示像“e”这样的带有重音符号的特殊字符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3812949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I show special characters like "e" with accent acute over it in HTML page?
提问by Pouya BCD
I need to put the name of some universities on my web page. I have typed them as they were but in some browser or maybe some computers they appear differently. For example, "Universite de Moncton" should have the 2nd "e" in Universite with an accent acute over it. Could you please help about it.
我需要把一些大学的名字放在我的网页上。我按原样输入它们,但在某些浏览器或某些计算机中,它们的显示有所不同。例如,“Universite de Moncton”应该有 Universite 中的第二个“e”,上面带有重音。你能帮帮忙吗。
回答by Gumbo
If you're using a character set that contains that character, you can use an appropriate character encoding and use it literally:
如果您使用的字符集包含该字符,则可以使用适当的字符编码并按字面意思使用它:
Universit?é de Moncton
Don't forget to specify the character set/encoding properly.
不要忘记正确指定字符集/编码。
If not, you can use an HTML character reference, either a numeric character referencethat denotes the code point of the character in the Universal Character Set (UCS):
如果没有,您可以使用HTML 字符引用,或者是表示通用字符集 (UCS) 中字符代码点的数字字符引用:
Universit?é de Moncton
Universit?é de Moncton
Or using an entity reference:
或使用实体引用:
Universit?é de Moncton
But this entity is just a named representation of the numeric character reference (see the list of entity references that are defined in HTML 4):
但该实体只是数字字符引用的命名表示(请参阅HTML 4 中定义的实体引用列表):
<!ENTITY eacute CDATA "é" -- latin small letter e with acute,
U+00E9 ISOlat1 -->
回答by scunliffe
You can use UTF-8 HTML Entities:
您可以使用 UTF-8 HTML 实体:
è è
é é
ê ê
ë ?
Here's a handy search page for the UTF-8 Character Map
这是一个方便的UTF-8 字符映射搜索页面
回答by asthasr
回答by Randy the Dev
By typing it in to your HTML code. é
<--You can copy and paste this one if you want.
Microsoft windows has a character map for accessing characters not on your keyboard, it's called Character map
.
通过将其输入到您的 HTML 代码中。é
<--如果需要,您可以复制并粘贴这个。Microsoft Windows 有一个字符映射表,用于访问不在键盘上的字符,称为Character map
.
回答by Adriano Varoli Piazza
I think from the mention that 'in some computers or browsers they appear differently' that the problem you have is with the page or server encoding. You must
我认为从“在某些计算机或浏览器中它们的外观不同”中可以看出,您遇到的问题在于页面或服务器编码。你必须
- encode the file correctly (how to do this depends on your text editor)
assign the correct encoding in your webpage, done with a meta tag
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
force the server encoding with, for example, PHP's
header()
function:header('Content-Type: text/plain; charset=ISO-8859-1');
- 正确编码文件(如何执行此操作取决于您的文本编辑器)
在您的网页中分配正确的编码,使用元标记完成
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
例如,使用 PHP 的
header()
函数强制服务器编码:header('Content-Type: text/plain; charset=ISO-8859-1');
Or, yes, as everyone has pointed out, use the html entities for those characters, which is always safe, but might make a mess when you try to find-replace in code.
或者,是的,正如每个人都指出的那样,对这些字符使用 html 实体,这总是安全的,但是当您尝试在代码中查找替换时可能会造成混乱。
回答by Scott
http://www.starr.net/is/type/htmlcodes.html
http://www.starr.net/is/type/htmlcodes.html
This site shows you the HTML markup for all of those characters that you will need :)
该站点向您展示了您需要的所有字符的 HTML 标记:)