p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning HTML, XHTML, CSS, and JavaScript (http://p2p.wrox.com/forumdisplay.php?f=541)
-   -   character encoding (http://p2p.wrox.com/showthread.php?t=85985)

justinneng December 9th, 2011 03:11 PM

character encoding
Hello all,
I am using dreamweaver cs5. when i start a new xhtml 1.0 strict page, among the default text that appears in the page there is this line,


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Now based on the book, i typed the xml declaration as follows right in the beginning of the page


<?xml version="1.0" encoding="iso-8859-1"?>
in the first code the charset is utf-8 while in the xml declaration the the encoding is iso-8859-1. are these two different values supposed to be the same? I am asking this because in the book on page 58 and 59, in the try it out section there is an example where the encoding is iso-8859-1. so is the charset in the <meta http-equiv.... line (page 59).

bitnap December 11th, 2011 02:27 PM

Yes they should be the same. Since your Dreamweaver is set to UTF-8, I would continue to use UTF-8 for the meta tag, and if you do include an XML Declaration it should have the same (but fewer people seem to be using the XML Declaration these days on web pages).

I'm not an expert on this, but to try and explain a bit more:

First, you need to consider the characters that you want to use on your page. iso-8859-1 is OK for Western Europan languages such as English, French and German, but if you want to deal with Japanese, Chinese, Thai, Hindi or many others the characters are not included in iso-8859-1 and you should use UTF-8.

Second, you need to know how your program is saving the code. The actual html file for the page must be saved as UTF-8 / iso-8859-1 (there is no point writing one of these in the source code if the file is not saved in that same format). In Dreamweaver, I think you go to the preferences menu, and select the New Document options from the left then you will see an option that says "Default encoding" and you probably have UTF-8 selected there. This is fine because it should save it in that format.

So what happens is that, if a file is saved in iso-8859-1 (also often known as Latin-1), but contains characters from other characters not supported in it, then they will not show up correctly (that is when you might see that diamond shape with a question mark in it).

justinneng December 11th, 2011 03:07 PM

Thanks @bitnap
thank there @ bitnap.

i guess i should go for utf-8 encoding since there are lot of chances hindi may come into picture.

In preferences, the default encoding is already utf-8. perhaps that's why the default meta tag is utf-8.

anyway thanks once again!

All times are GMT -4. The time now is 01:58 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.