-1

I have some characters coming from database that are obscure if I use UTF-8 in HTML5. But if I use

<meta charset="ISO-8859-1"> 

instead then those characters become clear on the browser and looks fine. References suggest that UTF-8 is the preferred character encoding in HTML5.

Update 1: The Obscure character is shown as �

kta
  • 19,412
  • 7
  • 65
  • 47
  • I found a possible duplicate http://stackoverflow.com/questions/9314724/strange-character-issue-between-utf-8-and-iso-8859-1-character-sets-need-explan?rq=1 – kta Feb 11 '14 at 03:26
  • Another Possible duplicate: http://stackoverflow.com/questions/3715264/how-to-handle-user-input-of-invalid-utf-8-characters – kta Feb 11 '14 at 03:58
  • 1
    possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – deceze Feb 11 '14 at 08:32

1 Answers1

4

No, you should definely not “use UTF-8” in the sense of declaring UTF-8 as the encoding, if your document is in fact not UTF-8 encoded. This applies to any other encoding, too.

UTF-8 is indeed the preferred encoding, but this means actually using it, in addition to declaring it.

So unless you know how to make the characters UTF-8 encoded when inserted into an HTML document, you should declare the encoding that is actually used.

Note that ISO-8859-1 will actually be taken as windows-1252 (by browser traditions and by HTML5 drafts).

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390