I am coding a site, whose main language is Portuguese, which has a lot of 'unusual' chars, like `, ´,开发者_JAVA技巧 ~, and ç.
I if don't use the & directive of HTML, the words appear all messed up on the browser. So I can write a á
(e.g) whenever I need to, but that's very troublesome, since the Portuguese language is full of 'unusual' chars, as I mentioned.
I suppose there is a way around this. Which one?
Btw, I have added this to the top of all the pages of the website, but it didn't make any difference.
<?xml version="1.0" encoding="utf-8"?>
Use a meta tag in your <head>
:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- Set your editor to save in a known encoding (UTF-8 unless you have a good reason to use something else)
- Specify that encoding in your HTTP Headers
- Make sure the encoding doesn't get changed by any program code or database storage along the way.
- Do not use an XML prolog (
<?xml version="1.0" encoding="utf-8"?>
), it triggers Quirks mode in IE6
See also:
- Character encodings for beginners
- Handling character encodings in HTML and CSS
精彩评论