Why does a diamond with a questionmark in it � appear in my HTML?

前端 未结 4 536
予麋鹿
予麋鹿 2020-12-03 02:58

I have an unorder list, and � often (but not always!) appears where I have have two spaces between characters. What is causing this, and how do I prevent it?

相关标签:
4条回答
  • 2020-12-03 03:19

    This specific character � is usually the sign of an invalid (non-UTF-8) character showing up in an output (like a page) that has been declared to be UTF-8. It happens often when

    • a database connection is not UTF-8 encoded (even if the tables are)

    • a HTML or script source file is stored in the wrong encoding (e.g. Windows-1252 instead of UTF-8) - make sure it's saved as a UTF-8 file. The setting is often in the "Save as..." dialog.

    • an online source (like a widget or a RSS feed) is fetched that isn't serving UTF-8

    0 讨论(0)
  • 2020-12-03 03:19

    I had the same issue when getting an HTML output from an XSLT. Along with Pradip's solution I was also able to resolve the issue using UTF-32.

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-32" />
    
    0 讨论(0)
  • 2020-12-03 03:21

    It's a character-set issue. Get a tool that inspects the response headers of the server (like the Firebug extension if you're using Mozilla Firefox) to see what character set the server response is sending with the content. If the server's character-set and the HTML character set of the actual content don't match up, you will see some strange looking characters like those little black diamond squares.

    0 讨论(0)
  • 2020-12-03 03:22

    I had the same issue ....

    You can fix it by adding the following line in your template !

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    

    For more details :

    Read this - http://blog.salientdigital.com/2009/06/06/special-characters-showing-up-as-a-question-mark-inside-of-a-black-diamond/comment-page-1/#comments

    0 讨论(0)
提交回复
热议问题