Strange characters appear on website?

Sometimes, when copying text from notepad into the website coding, strange characters appear on the live website, can’t remember all the instances over the years, but the latest this morning, was the pound sign £ I have the doctype setup as <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN””>

Any help much appreciated.

Hi Dez,

Without an example, it’s hard to say what it is, but at a guess it might be:

  1. Notepad has some sort of bug that inserts strange characters at the beginning sometimes, better using a different editor.
  2. You might have not included the meta in the head for character encoding: <meta charset=“UTF-8”>
  3. The file might not be saved in with the right character encoding
  4. Could be something in your code (Server side or client side)


Sorry, the other bit of code existing in the page is :

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

I have seen BOM related issues before, but as this is an extraneous pound symbol my guess would be the page has a table and the pound symbol is in the wrong place. eg.
instead of

Does the page pass validation?

It’s in the right place. How/where do I validate it please?

What do I do next on the not sures above please?

Sorry, I’ve used if for so long so many times it never occurs to me others might not.

When you save the file, editors usually have the option for saving it in a particular format.

So your file is saved in a particular format, but you need to tell the browser what format it is too, so you have to put that in the header. (looks like you have already done that). Check here.

With regards to your code, I can’t help. Too many possibilities. I would say it is more likely one of the other things though.

Thanks all for your help. I wonder, from another direction. Is there anyone here, who, when putting just the singular £ sign, that it appears on the internet, as just that, a £ sign?

I’m not sure I’ve understood your question. Yes, I’ve used £ in various sites, and no, I’ve had no problems with it.

You could try using £

Yes, as said, that’s pretty normal. To be safe, make sure your encoding is utf-8. Otherwise, follow -RT-'s advice and use &pound;

Sorry, I’m getting lost and maybe I’m not making myself clear, when I want to enter a £ sign, I just want enter simply that. So, just doing one step at a time, in the page itself I have:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN””>
<html lang=“en”>
<meta http-equiv=“Content-Type” content=“text/html;charset=iso-8859-1”/>
Is the coding above correct to get on the way to achieving the aim please?

To be safe:
If you want to use only £ then you should use UTF-8
If you want to use iso-8859-1 then you should use £

iso-8859-1 does support £ but problems can surface (eg. AJAX)

But TBH I think your problem has more to do with your text editor setting (or maybe database encoding?)

Replace that code with this:

<!DOCTYPE html>
<html lang="en">
<meta charset="[COLOR="#FF0000"]utf-8[/COLOR]">

The code you posted is archaic and signals that it’s an out of date site. However, they key bit is the utf-8 encoding.

To clarify what I said above, I use £ with utf-8 and have never had a problem.

I have also in the past used £ with iso-8859-1 and again, encountered no problems.

(Actually, to be honest, I quite often use £ with utf-8, out of force of habit - and that doesn’t cause problems either. :slight_smile: The only issue, as others have said, is with using £ in iso-8859-1.)

[ot]Bizarrely, this page is being served with charset=ISO-8859-1 and the £ still works, but I guess it’s not reliable generally.

Possibly could have something to do with the browser being extra helpful.

Many, many thanks. very helpful. The weird (and confusing) thing, is that I just tried it with <meta http-equiv=“Content-Type” content=“text/html;charset=iso-8859-1”/> put in £ and that’s how it appeared.

Sound’s like you were (are) saving the file in iso-8859-1 character encoding instead of UTF-8 character encoding to me.