-->

can't show chinese character for html on linux

2019-09-14 22:35发布

问题:

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.



标签: html utf-8 cjk