Document Encoding/Charset

P

Pietro

Im confused by these two lines that I include in my html:

<?xml version="1.0" encoding="utf-8"?>
....
<meta http-equiv="content-type" content="text/html; charset=utf-8">

Can I choose any encodings I want here or is the correct choice
related to how my editor saves my files? Does using UTF-8 offer a
portability advantage over the other encodings? How to choose?
 
D

David Dorward

Im confused by these two lines that I include in my html:
<?xml version="1.0" encoding="utf-8"?>

You should not be including this line in XHTML served as text/html
(see Appendix C of the XHTML 1.0 spec). (For that matter, XHTML is
generally a poor idea on the WWW). If you aren't using XHTML then you
shouldn't be using it either.
<meta http-equiv="content-type" content="text/html; charset=utf-8">

And if you are using XHTML then you're missing a slash.
Can I choose any encodings I want here or is the correct choice
related to how my editor saves my files?

You need to specify the encoding the document is saved in. A good
editor will let you choose. Note that real HTTP headers trump any
claim in the document and that they are the correct place to tell the
client what encoding you are using.
Does using UTF-8 offer a portability advantage over the other encodings?

It can encode pretty much any character you are likely to need, and
does have wide support.
How to choose?

If in doubt, UTF-8.
 
H

Harlan Messinger

David said:
You should not be including this line in XHTML served as text/html
(see Appendix C of the XHTML 1.0 spec). (For that matter, XHTML is
generally a poor idea on the WWW). If you aren't using XHTML then you
shouldn't be using it either.


And if you are using XHTML then you're missing a slash.


You need to specify the encoding the document is saved in.

More precisely, the encoding in which the document is transmitted to the
client, though ordinarily I guess that would be the same as the encoding
in which it's saved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top