Html 如何在HTML中显示汉字
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20670034/
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 to display chinese character in HTML
提问by user3014926
I have created web page using Chinese. When I view the page with Google chrome, all Chinese characters are corrupted. Do I have to add something in HTML page?
我用中文创建了网页。当我用谷歌浏览器查看页面时,所有汉字都已损坏。我必须在 HTML 页面中添加一些东西吗?
回答by Eliezer Bernart
There are two ways to define the encoding of your page. You should include inside your <head>
tags an encoding tag, two ways to do that follow below:
有两种方法可以定义页面的编码。你应该在你的<head>
标签中包含一个encoding tag,下面有两种方法:
Short way:
简短的方法:
<meta charset="utf-8">
Long way:
很长的路要走:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
You can have more details about the difference between these two ways in this question:
您可以在此问题中详细了解这两种方式之间的区别:
If you want to see a real example, take a look in the weibo.comsource code at this line of code.
回答by rulebot
Make sure to use UTF-8 or a comparable encoding. This can be made sure in the http headers:
确保使用 UTF-8 或类似的编码。这可以在 http 标头中确定:
Content-Type: text/html; charset=utf-8
回答by Justin Chan
use utf-8 character set otherwise it will all be code
remember <meta charset="utf-8"
使用utf-8字符集,否则都是代码记住 <meta charset="utf-8"
回答by Choppin Broccoli
Ensure you are using the UTF-8 character set
确保您使用的是 UTF-8 字符集