Forum Moderators: open

Message Too Old, No Replies

UTF-8: Can I directly use special characters in my code?

         

Jeremy_H

3:54 am on Apr 14, 2006 (gmt 0)

10+ Year Member



If I'm using charset utf-8, do I have to use code like © and ˜ , or can I just use the actual characters directly in my code?

Are their compatibility issues/code saving issues?

Thanks

chrisrock79

6:11 am on Apr 14, 2006 (gmt 0)

10+ Year Member



This may help
[w3.org ]

encyclo

5:41 pm on Apr 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In most situations you can use the special characters straight in the document without escaping or converting at all. This is one of the big advantages with UTF-8 over more limited older charsets such as ISO-8859-1.

Browser support for UTF-8 is excellent these days, with IE5.x and above and all Mozilla/Firefox/Safari/Konqueror and Opera (above about version 5) browsers having no problem either.

The only problems occur when the display font does not have the appropriate glyph for the symbol (which is equally a problem if you use entities), when the page is saved and viewed offline (you should always use a meta charset element even if you set the charset with a HTTP header), or in much older user agents such as Netscape 3.x or 4.x.

Make sure that your editor is really saving the document as UTF-8 rather than assuming windows-1252 - you can't just change the meta charset and expect it to work. Most proper web editors can handle UTF-8, including Dreamweaver, but some non-web editors such as Notepad will cause problems.