Search code examples
htmlencodingcharacter-encodingspecial-characters

How come the following characters are displayed in ISO-8859-1?


I have the following html:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
    会意字 / 會意字 huìyìzì
</body>

When I run it in firefox, it displays the Chinese characters just fine. How come it works with the ISO-8859-1 characterset? I thought you needed UTF-8?


Solution

  • I can't reproduce your successful rendering:

    Not rendering correctly in Firefox

    … but HTML 5 defines a fairly complex character encoding detection method which doesn't pay any attention to <meta> until step 9.

    In general, you should avoid encodings other than UTF-8 and definitely should not lie about the encoding of the document.