Html 如何让网站显示“?”之类的标志 和 ”?”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9219271/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:25:56  来源:igfitidea点击:

How to make the website show signs like "?" and "?"?

htmlunicodeencodingfontsspecial-characters

提问by corazza

I'm making a website that is in Croatian, and I need to use signs like: "?", "?", "?", "?" and "?". They are currently displayed as little boxes.

我正在制作一个克罗地亚语网站,我需要使用以下符号:“?”、“?”、“?”、“?” 和 ”?”。它们目前显示为小盒子。

Info:

信息:

  • I use Notepad ++.
  • I set the encoding there to UTF-8.
  • I put the following line of HTML in: <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  • 我使用记事本++。
  • 我将那里的编码设置为 UTF-8。
  • 我将以下 HTML 行放入: <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

However, it does not work. Even Notepad ++ can't display my characters using UTF-8, so that would suggest that I should probably use something else...

但是,它不起作用。甚至 Notepad ++ 也无法使用 UTF-8 显示我的字符,因此这表明我可能应该使用其他东西...

回答by Joe

http://webdesign.maratz.com/lab/utf_table/

http://webdesign.maratz.com/lab/utf_table/

Use HTML entities, for example

使用 HTML 实体,例如

  • ? : &#269;
  • ? : &#382;
  • ? :&#269;
  • ? :&#382;

回答by 0b10011

This sounds more like a font issue than a character encoding issue. If it were a character encoding issue, the characters would most likely be displayed as 2+ ASCII characters. The boxes, however, typically mean the character encoding is correct, but that specific character is not available in the font being used (which is especially common with lesser-used fonts). This would explain why it's behaving incorrectly in both the website and Notepad++.

这听起来更像是字体问题而不是字符编码问题。如果是字符编码问题,字符很可能会显示为 2+ ASCII 字符。然而,这些框通常意味着字符编码是正确的,但该特定字符在所使用的字体中不可用(这对于较少使用的字体尤其常见)。这将解释为什么它在网站和 Notepad++ 中都表现不正确。

To fix the issue, simply use a different font in your editor and website.

要解决此问题,只需在您的编辑器和网站中使用不同的字体。

Note:I recommend a widely used font for the best chance of it working. Specifying a generic name in the website (e.g. serifor sans-serif) will probably have even better results, as the OS/browser would decide on the best font to use.

注意:我推荐一种广泛使用的字体,以使其工作的最佳机会。在网站中指定通用名称(例如serifsans-serif)可能会产生更好的结果,因为操作系统/浏览器将决定使用的最佳字体。

回答by Quentin

In short, be consistent about your character encoding throughout.

简而言之,始终保持您的字符编码一致。

  1. Configure your editor to save in the encoding you want
  2. If you use any server side programming, make sure it isn't transcoding your data
  3. If you use a database, make sure it is configured to use the same encoding
  4. Configure your server to emit a Content-Type header that specifies that encoding
  5. Use the meta tag in your question
  1. 配置您的编辑器以保存所需的编码
  2. 如果您使用任何服务器端编程,请确保它没有对您的数据进行转码
  3. 如果您使用数据库,请确保将其配置为使用相同的编码
  4. 配置您的服务器以发出指定该编码的 Content-Type 标头
  5. 在您的问题中使用元标记

The W3C provides useful material on encodings that starts here.

W3C 提供了有关编码的有用材料,从这里开始

回答by BlueCacti

A useful site for special characters and their ASCII-codes: CopyPaste Character

特殊字符及其 ASCII 码的有用站点:CopyPaste Character

To 'type' them, use the alt codes.
However, to use them in your site, you'll better use the HTML codes like you can find on CPC

要“键入”它们,请使用替代代码。
但是,要在您的网站中使用它们,您最好使用在 CPC 上可以找到的 HTML 代码

回答by egrunin

As a test, try this:

作为测试,试试这个:

<span style="font-family:Arial Unicode MS">
    ? ? ? ? ?
</span>

You should be able to see your characters correctly.

您应该能够正确地看到您的角色。

回答by Oleg Mikheev

I've just copied and pasted a line from your question along with your meta tag, placed it into a plain text file in vi.

我刚刚复制并粘贴了您问题中的一行以及您的元标记,并将其放入vi.

It works just fine - all characters are displayed fine: http://www.dusystems.com/tmp/1.html

它工作得很好 - 所有字符都显示正常:http: //www.dusystems.com/tmp/1.html

If you can't do the same with your editor then the problem is with the editor and not character sets and encodings.

如果你不能用你的编辑器做同样的事情,那么问题出在编辑器而不是字符集和编码上。

If you're on Windows you can use its built-in Notepad to edit UTF-8 files. Open Notepad, type all of your special characters, add the meta tag. When doing Save As select UTF-8from the Encoding drop-down in the dialog. Save as something.html and open in IE. It will 100%work.

如果您使用的是 Windows,则可以使用其内置的记事本来编辑 UTF-8 文件。打开记事本,输入所有特殊字符,添加元标记。执行另存为时,从对话框的编码下拉列表中选择UTF-8。另存为 something.html 并在 IE 中打开。它将100%工作。