ISO-8859-1 vs. UTF-8?

CssXhtmlUnicodeUtf

Css Problem Overview


What should be used and when? Or is it always better to use UTF-8? Or ISO-8859-1 still has importance in specific conditions?

Is the haracter set related to geographic region?


Is there a benefit to using the code @charset "utf-8";?

Or like this <link type="text/css; charset=utf-8" rel="stylesheet" href=".." />

at the top of the CSS file?

I found for this

> If Dreamweaver adds the tag when you > add embedded style to the document, > that is a bug in Dreamweaver. From the > W3C FAQ: > > "For style declarations embedded in a > document, @charset rules are not > needed and must not be used." > > The charset specification is a part of > CSS since version 2.0 (may 1998), so > if you have a charset specification in > a CSS file and Safari can't handle it, > that's a bug in Safari.

And add accept-charset in the form:

<form action="/action" method="post" accept-charset="utf-8">

And what should be used if I use the XHTML doctype?

<?xml version="1.0" encoding="UTF-8"?>

or

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Css Solutions


Solution 1 - Css

Unicode is taking over and has already surpassed all others. I suggest you hop on the train right now.

Note that there are several flavors of unicode. Joel Spolsky gives an overview.

Unicode is winning (Graph current as of Feb. 2012, see comment below for more exact values.)

Solution 2 - Css

UTF-8 is supported everywhere on the web. Only in specific applications is it not. You should always use UTF-8 if you can.

The downside is that for languages such as Chinese, UTF-8 takes more space than, say, UTF-16. But if you don't plan on going Chinese, or even if you do go Chinese then UTF-8 is fine.

The only cons against using UTF-8 is that it takes more space compared to various encodings, but compared to western languages it takes almost no extra space at all, except for very special characters, and those extra bytes you can live with. We are in 2009 after all. ;)

Solution 3 - Css

If you want world domination, use UTF-8 all the way, because this covers every human character available at the world, including Asian, Cyrillic, Hebrew, Arabic, Greek and so on, while ISO-8859 is only restricted to Latin characters. You don't want to have Mojibake.

Solution 4 - Css

I find ISO 8859-1 very useful on a couple of sites where I have clients sending me text files that were created in Word or Publisher, that I can easily insert into the midst of PHP code and not worry about it - especially where quotes are concerned.

These are local, U.S. companies, and there is literally no other difference in the text on the pages, and I see no disadvantage in using that character set on those particular pages. All others are UTF-8.

Solution 5 - Css

  • ISO 8859-1 is a great encoding to use when space is a premium and you are only ever going to want to encode characters from the basic Latin languages it supports. And you are never ever ever going to ever have to ever contemplate ever upgrading your application to support non Latin languages.

  • UTF-8 is a fantastic way to (a) use the large code base of 8 bits per character code libraries there are that already exist, or (b) be a euro snob. UTF-8 encodes standard ASCII in one byte per character, Latin 1 in 2 bytes per character, Eastern European and Asian languages get three bytes per character. It possibly goes up to four bytes per character if you start trying to encode ancient languages that don’t exist in the basic multilingual plane.

  • UTF-16 is a great way to start a new codebase from scratch. It’s completely culture neutral - everyone gets a fair handed two bytes per character. It does need four bytes per character for ancient/exotic languages - which means - in the worst case - it’s as bad as its big brother:

  • UTF-32 is a waste of space.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJitendra VyasView Question on Stackoverflow
Solution 1 - Cssnes1983View Answer on Stackoverflow
Solution 2 - CssTor ValamoView Answer on Stackoverflow
Solution 3 - CssBalusCView Answer on Stackoverflow
Solution 4 - CssRationalRabbitView Answer on Stackoverflow
Solution 5 - CssChris BeckeView Answer on Stackoverflow