简体   繁体   English

如何删除html页面上以西班牙语显示的字符

[英]How to remove � characters appearing in spanish language on html page

I want to show multiple languages on my page, for Spanish I am getting question marks with black backgrounds. 我想在页面上显示多种语言,对于西班牙语,我会收到黑色背景的问号。

Result on html page: 
contrase�

Original Spanish:
contraseña

charset is utf-8 and these Spanish words are stored in an array. charset是utf-8,这些西班牙语单词存储在数组中。

Looks like an encoding issue. 看起来像是编码问题。 You will need to: 您将需要:

  1. Store the data in UTF-8 (assuming this coming from a db, etc) 将数据存储在UTF-8中(假设此数据来自数据库等)
  2. Encode the page in UTF-8 用UTF-8编码页面
  3. Ensure your server is sending the right header 确保您的服务器发送正确的标题

You can find more information on encoding in this w3 article 您可以在此w3文章中找到有关编码的更多信息。

You could replace the special letters with these 您可以将这些特殊字母替换为

So in html code it would look like this: 所以在html代码中,它看起来像这样:

Contrasña

and on html page: 并在html页面上:

Contrasña Contrasña

Try the following 尝试以下

<head>
    <title>An XHTML 1.0 Strict standard template</title>
   // this is important to display specialcharacters
    <meta http-equiv="content-type" 
   content="text/html;charset=utf-8" /> 
</head>

From the symptoms (“ ” indicates byte-level data error: bytes that do not represent any character in the encoding being applied), it seems obvious that the data is not in fact UTF-8 encoded but probably ISO-8859-1 encoded. 从症状来看(``...''表示字节级数据错误:字节不代表正在应用的编码中的任何字符),显然数据实际上不是UTF-8编码的,可能是ISO-8859-1编码的。 If this the case, utf8_encode is needed. 如果是这种情况,则需要utf8_encode

在这些情况下,ASCII代码更好,否则它将无法在所有浏览器中正确显示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM