can't show chinese character for html on linux server

房东的猫 提交于 2019-12-12 02:48:22

问题


This webpage can't show chinese character, Can I find a way to display these characters ?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>


<html>
    <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     <META HTTP-EQUIV="Content-language" CONTENT="zh">
        <link rel="stylesheet" href="css/reset.css" type="text/css" media="screen" charset="GBK" />
        <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
        <script type="text/javascript" src="js/jquery.cookie.js"></script>
        <script type="text/javascript" src="js/counter.js"></script>
    </head>
    <body>
        <h1>Is your sign of zodiac in this picture ?星座</h1>
        <img src="a.png">
        <div id="page1_yes" >
            <input type="button" name="yesb" value="Yes">
        </div>
        <div id="page1_no">
            <input type="button" name="nob" value="No">
        </div>
    </body>
</html>

-----------result is here: Is your sign of zodiac in this picture ?ÐÇ×ù


回答1:


Your web server is most likely outputting a Content-Type HTTP header which is set to ISO-8859-1 or something else, overruling your <meta> Content-Type tag. Configure your web-server to output an HTTP header with the correct encoding and/or make sure your HTML is actually saved in UTF-8.




回答2:


The document displays OK when viewed locally. Something odd has happened when you have saved it in a file and uploaded to a server. It is not a simple problem of wrong encoding as @deceze suggested, since when saved in UTF-8 and interpreted as ISO-8859-1 for example, the Chinese characters appear as 星座 (six characters, since each of the Chinese characters has a three-byte representation in UTF-8).

Since you see the characters as four characters in the ISO-8859-1 range, perhaps they were actually saved in a UTF-16 encoding, then erroneously code-converted via some mapping and finally interpreted as if the resulting bytes were ISO-8859-1 encoded. Describing the process of saving and uploading the file and especially giving the URL of an uploaded document might help.



来源:https://stackoverflow.com/questions/9713564/cant-show-chinese-character-for-html-on-linux-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!