39

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 weird black diamond with a question mark in the center of it

Here's what I mean
screen

It seems this is happening all over the site wherever these symbols appear. I've never seen this before, can anyone explain it to me?

Suggestions on how to fix it would also be greatly appreciated.

See http://test.rfinvestments.co.za/index.php?c=team for a clear look at the problem.

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
Ortund
  • 8,095
  • 18
  • 71
  • 139
  • Which encoding did you write the website in? Which encoding does the browser see? What’s the actual code? There’s too little information here to answer the question. The screenshot URL 404s. – Konrad Rudolph Nov 03 '10 at 11:52

7 Answers7

48

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.

joni
  • 5,402
  • 1
  • 27
  • 40
  • hadn't bothered looking at it. They're probably ascii... can you tell me how to set that? – Ortund Nov 03 '10 at 12:00
  • @Logan Young after you know which type of encoding your editor produces, you just have to set that encoding in the meta tag I posted above. What editor do you use? – joni Nov 03 '10 at 12:01
  • @Logan I downloaded your web site, but `enca` and `file` aren't able to recognize the encoding, that's somewhat strange. Again, which editor do you use? – joni Nov 03 '10 at 12:05
  • umm. It should be possible to save from notepad as iso-8859 or utf-8. Try it and replace the encoding in the meta tag. – joni Nov 03 '10 at 12:07
  • Safe to say the files don't just have ASCII characters in, otherwise you wouldn't have this problem. Did you write this content in Notepad, or was it pasted in from e.g. Word? – Gareth Nov 03 '10 at 12:11
  • “If you're on an Unix system, just type `file file.html`” — if you’re on Mac OS X, it looks like you’ll need `file -I file.html`. – Paul D. Waite Nov 03 '10 at 12:33
6

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.

Karlgoldstraw
  • 618
  • 2
  • 11
  • 25
5

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

I just replace ' with &rsquo; 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&rsquo;s label, width and type-ahead options
Ajay2707
  • 5,690
  • 6
  • 40
  • 58
2

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.

  • 1
    Copy-paste across editors can cause this. @Leonid Your answer helped to look into the right direction. – ARK Aug 18 '17 at 18:25
  • This was my issue today, ' vs ’. They look the same BUT THEY ARE NOT – Ack Jan 03 '21 at 03:34
2

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.

user6784003
  • 121
  • 2
1

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

Testilla
  • 602
  • 8
  • 21
0

What I really don't understand with this kind of problem is that the html page I ran as a local file displayed perfectly in Chromium browser, but as soon as I uploaded it to my website, it produced this error.

Even stranger, it displayed perfectly in the Vivaldi browser whether displayed from the local or remote file.

Is this something to do with the way Chromium reads the character set? But why only with a remote file?

I fixed the problem by retyping the text in a simple text editor and making sure the single quote mark was the one I used.

  • Welcome to stackoverflow. We are Q&A not a discussion forum. If you have further questions, start a new question post and link to the existing one. – Simon.S.A. Dec 16 '18 at 20:07