Which is better UTF-8 or ISO-?


Someone asked today on a mailing list whether they should be using UTF-8 or “ISO” encoding for sending email. What’s the best choice depends on some of the details of the situation, but here’s the answer I gave:
UTF-8 will work for pretty much anything, as it’s just an 8 bit encoding scheme for Unicode (which is supposed to be the one character encoding to rule them all). It’s well supported in most languages and development environments – Windows has been native UTF-16 under the covers since the mid 90s, for instance – and typical messages that use mainstream glyphs should render well from utf-8 in most western MUAs and browsers.
There are still a very few old or broken clients out there that will not handle UTF-8 well but (outside the asian language market, where there’s still some non-ASCII, non-Unicode legacy usage) they’re typically ones that don’t really handle any character set encoding well and the only thing safe to send to them is either plain ASCII or whichever ASCII superset their OS happens to support natively (which is probably an argument for sending Windows-1252 codepage, but not a terribly strong one).
The various extended ASCIIs (such as ISO-8859-*) will only work for messages that are written solely using characters from that character set. If you have even one character in a message that cannot be expressed in ISO-8859-1, then you can’t use ISO-8859-1 to send that message.
ISO-8859-1 (aka Latin1) is fairly sloppy in some respects – it has no apostrophe, nor single quotes, for instance – but it can handle an awful lot of languages, from Kurdish to Swahili. It can’t handle Dutch, Estonian, Finnish, Hungarian and Welsh particularly well, nor can it show the Euro symbol (ISO-8859-14 or -15 are needed for some characters there).
A common problem is that many people (and the software they write) think that Windows uses Latin1. It doesn’t, it uses Windows-1252. If you accept messages written on Windows, using the Windows-1252 code page, and throw them out on the wire as ISO-8859-1 what you end up with is not quite right. It mostly works, as the two codepages overlap quite a bit, but they have different glyphs in the 0x80-0x9f range. So if you use single or double quotes (“smart quotes”), or the Euro symbol, or ellipses, or bullet, or the trademark symbol in your message they’ll be garbled. This is so common that some mail clients and web browsers will actually treat a document that claims to be ISO-8859-1 as Windows-1252, but that’s a bug workaround and not something it’s really safe to rely on.
If you’re doing personalized messages, and you’re sending one of them to Győző and one of them to Eiður then you may have to use different character sets for the two messages. If you’re talking about Győző and personalizing it for Eiður then you might find things break horribly.
Someone probably has some concrete data on mail client character set support, broken down by region and language, but my understanding is that this is a reasonable approach:

  1. If you’re sending any entirely non-ASCII messages (asian languages, primarily) then it’s way more complex than it should be, and you need to find someone who really understands the deployment of BIG5 and ShiftJIS and so on if you want to dial in to perfection. If you don’t have someone like that, UTF-8 is your best bet.
  2. If your tool chain supports non-ASCII messages, and you want to choose a single encoding, go with UTF-8. If the UTF-8 you end up sending is entirely, or almost entirely, ASCII then this will render well even on the tiny fraction of mail clients that don’t support character sets. (This is what I’d do).
  3. If your tool chain supports non-ASCII, but almost all your messages are plain ASCII and you want to be clever, encode each message separately. That’ll mean storing the templates and mailmerge data as UTF-8 probably, then converting the resulting message to ASCII if possible. That’s actually a lot simpler to do than it sounds, as a valid UTF-8 message that can be converted to ASCII is already an ASCII message, so all you need to do is set the charset to UTF-8 if there’s any byte bigger than 127 in the message or to us-ascii otherwise.
  4. If your toolchain was written to support only truly 8 bit character sets, or if that’s all you ever expect to send, then ISO-8859-15 is about as good as you can do.

If you’re accepting messages via a web front end, or any other path that could lead to stuff being copy and pasted or uploaded from Windows, look out for the Windows-1252 issues, and convert the provided message to whatever format you’re storing templates as (probably utf-8).
Then, once you have the message, be careful to send it over the wire as 7 bit ASCII, probably using quoted-printable encoding, to make sure it isn’t thrown away or transcoded to base64 en-route.

About the author


This site uses Akismet to reduce spam. Learn how your comment data is processed.

By steve

Recent Posts


Follow Us