-3

Iam using a php web site which ia by default has iso-8859-1 header type in html page. I had changed it to utf-8 then the special characters were showing in different way [ not rendering properly]

Edit: Header:

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

echoing the string which is showing as mentioned below:

1.  Nytt filter f�r v�lja spr�k och aktiva Medarbetare 

May i know the reason.

Thanks

Srinivas
  • 1,516
  • 3
  • 17
  • 27

1 Answers1

1

If you see the UNICODE REPLACEMENT CHARACTER �, that means the browser is interpreting the document as UTF-8 (or at least as some Unicode encoding). The � character means that the byte sequence at this spot could not be processed correctly as Unicode character. This means the encoding declaration, the <meta> tag, works just fine as it should, but your document is not actually UTF-8 encoded.

The <meta> tag just tells the browser what encoding the document is supposedly in, so the browser can parse it correctly. If you tell the browser the document is encoded in UTF-8, then you need to actually encode the document in UTF-8! Just changing the meta tag doesn't magically transform the document into another encoding.

Also see UTF-8 all the way through.

Community
  • 1
  • 1
deceze
  • 510,633
  • 85
  • 743
  • 889
  • thanks for your reply, iam using notepad++ and i changed encode type to utf-8 also with meta tag. but still browser � showing these chars – Srinivas Oct 17 '13 at 09:46
  • How exactly did you "change encode type to utf-8"? If you check in your browser in the *View* menu under *Encoding* and explicitly select UTF-8, does it still look that way? If so, the file is *not* actually UTF-8 encoded. – deceze Oct 17 '13 at 09:51
  • in editor Menu -> Encodeing -> UTF8 then string has became like this : tillXE4nglig otherwise it was like this :tillgänglig – Srinivas Oct 17 '13 at 09:54
  • I don't know Notepad++, but this sounds wrong. What you apparently did was tell Notepad++ to *interpret* your document in UTF-8, but not to change its encoding to UTF-8. The same way you incorrectly told the browser to interpret a document which isn't UTF-8 as UTF-8. Use *File → Save As...* and choose UTF-8 there, or something along those lines. The editor still must display the characters correctly, if they're already screwed up in the editor you're doing it wrong. – deceze Oct 17 '13 at 09:59