Why do symbols like apostrophes and hyphens get replaced with black diamonds on my website?

前端 未结 7 1239
暖寄归人
暖寄归人 2020-12-08 13:27

A website I\'ve made has a few problems... On one of the pages, wherever there\'s an apostrophe (\') or a dash (-), the symbol gets replaced with a

相关标签:
7条回答
  • 2020-12-08 14:04

    I experienced the same problem when I copied a text that has an apostrophe from a Word document to my HTML code.

    To resolve the issue, all I did was deleted the particular word in my HTML and typed it directly, including the apostrophe. This action nullified the original copy and paste acton and displayed the newly typed apostrophe correctly

    0 讨论(0)
  • 2020-12-08 14:06

    I have the same issue in my asp.net web application. I solved by this link

    I just replace ' with ’ text like below and my site in browser show apostrophe without rectangle around as in question ask.

    Original text in html page
    Click the Edit button to change a field's label, width and type-ahead options
    
    Replace text in html page
    Click the Edit button to change a field’s label, width and type-ahead options
    
    0 讨论(0)
  • 2020-12-08 14:09

    Look at your actual html code and check that the weird symbols are not originating there. This issue came up when I started coding in Notepad++ halfway after coding in Notepad. It seems to me that the older version of Notepad I was using may have used different encoding to Notepad's++ UTF-8 encoding. After I transferred my code from Notepad to Notepad++, the apostrophes got replaced with weird symbols, so I simply had to remove the symbols from my Notepad++ code.

    0 讨论(0)
  • 2020-12-08 14:12

    If you are editing HTML in Notepad you should use "Save As" and alter the default "Encoding:" selection at the botom of the dialog to UTF-8. you should also include-

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    This un-ambiguously sets the correct character set and informs the browser.

    0 讨论(0)
  • 2020-12-08 14:14

    You need to change your text to 'Plain text' before pasting into the HTML document. This looks like an error I've had before by pasting straight from MS word.

    MS word and other rich text editors often place hidden or invalid chars into your code. Try using &mdash; for your dashes, or &rsquo; for apostrophes (etc), to eliminate the need for relying on your char encoding.

    0 讨论(0)
  • 2020-12-08 14:15

    It's an encoding problem. You have to set the correct encoding in the HTML head via meta tag:

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

    Replace "ISO-8859-1" with whatever your encoding is (e.g. 'UTF-8'). You must find out what encoding your HTML files are. If you're on an Unix system, just type file file.html and it should show you the encoding. If this is not possible, you should be able to find out somewhere what encoding your editor produces.

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