Why isn't everything we do in Unicode?

UnicodeInternationalization

Unicode Problem Overview


Given that Unicode has been around for 18 years, why are there still apps that don't have Unicode support? Even my experiences with some operating systems and Unicode have been painful to say the least. As Joel Spolsky pointed out in 2003, it's not that hard. So what's the deal? Why can't we get it together?

Unicode Solutions


Solution 1 - Unicode

Start with a few questions

How often...

  • do you need to write an application that deals with something else than ascii?
  • do you need to write a multi-language application?
  • do you write an application that has to be multi-language from its first version?
  • have you heard that Unicode is used to represent non-ascii characters?
  • have you read that Unicode is a charset? That Unicode is an encoding?
  • do you see people confusing UTF-8 encoded bytestrings and Unicode data?

Do you know the difference between a collation and an encoding?

Where did you first heard of Unicode?

  • At school? (really?)
  • at work?
  • on a trendy blog?

Have you ever, in your young days, experienced moving source files from a system in locale A to a system in locale B, edited a typo on system B, saved the files, b0rking all the non-ascii comments and... ending up wasting a lot of time trying to understand what happened? (did your editor mix things up? the compiler? the system? the... ?)

Did you end up deciding that never again you will comment your code using non-ascii characters?

Have a look at what's being done elsewhere

Python

Did I mention on SO that I love Python? No? Well I love Python.

But until Python3.0, its Unicode support sucked. And there were all those rookie programmers, who at that time knew barely how to write a loop, getting UnicodeDecodeError and UnicodeEncodeError from nowhere when trying to deal with non-ascii characters. Well they basically got life-traumatized by the Unicode monster, and I know a lot of very efficient/experienced Python coders that are still frightened today about the idea of having to deal with Unicode data.

And with Python3, there is a clear separation between Unicode & bytestrings, but... look at how much trouble it is to port an application from Python 2.x to Python 3.x if you previously did not care much about the separation/if you don't really understand what Unicode is.

Databases, PHP

Do you know a popular commercial website that stores its international text as Unicode?

You will (perhaps) be surprised to learn that Wikipedia backend does not store its data using Unicode. All text is encoded in UTF-8 and is stored as binary data in the Database.

One key issue here is how to sort text data if you store it as Unicode codepoints. Here comes the Unicode collations, which define a sorting order on Unicode codepoints. But proper support for collations in Databases is missing/is in active development. (There are probably a lot of performance issues, too. -- IANADBA) Also, there is no widely-accepted standard for collations yet: for some languages, people don't agree on how words/letters/wordgroups should be sorted.

Have you heard of Unicode normalization? (Basically, you should convert your Unicode data to a canonical representation before storing it) Of course it's critical for Database storage, or local comparisons. But PHP for example only provides support for normalization since 5.2.4 which came out in August 2007.

And in fact, PHP does not completely supports Unicode yet. We'll have to wait PHP6 to get Unicode-compatible functions everywhere.

So, why isn't everything we do in Unicode?

  1. Some people don't need Unicode.
  2. Some people don't care.
  3. Some people don't understand that they will need Unicode support later.
  4. Some people don't understand Unicode.
  5. For some others, Unicode is a bit like accessibility for webapps: you start without, and will add support for it later
  6. A lot of popular libraries/languages/applications lack proper, complete Unicode support, not to mention collation & normalization issues. And until all items in your development stack completely support Unicode, you can't write a clean Unicode application.

The Internet clearly helps spreading the Unicode trend. And it's a good thing. Initiatives like Python3 breaking changes help educating people about the issue. But we will have to wait patiently a bit more to see Unicode everywhere and new programmers instinctively using Unicode instead of Strings where it matters.

For the anecdote, because FedEx does not apparently support international addresses, the Google Summer of Code '09 students all got asked by Google to provide an ascii-only name and address for shipping. If you think that most business actors understand stakes behind Unicode support, you are just wrong. FedEx does not understand, and their clients do not really care. Yet.

Solution 2 - Unicode

  • Many product developers don't consider their apps being used in Asia or other regions where Unicode is a requirement.
  • Converting existing apps to Unicode is expensive and usually driven by sales opportunities.
  • Many companies have products maintained on legacy systems and migrating to Unicode means a totally new development platform.
  • You'd be surprised how many developers don't understand the full implications of Unicode in a multi-language environment. It's not just a case of using wide strings.

Bottom line - cost.

Solution 3 - Unicode

Probably because people are used to ASCII and a lot of programming is done by native English speakers.

IMO, it's a function of collective habit, rather than conscious choice.

Solution 4 - Unicode

The widespread availability of development tools for working with Unicode may be a more recent event than you suppose. Working with Unicode was, until just a few years ago, a painful task of converting between character formats and dealing with incomplete or buggy implementations. You say it's not that hard, and as the tools improve that is becoming more true, but there are a lot of ways to trip up unless the details are hidden from you by good languages and libraries. Hell, just cutting and pasting unicode characters could be a questionable proposition a few years back. Developer education also took some time, and you still see people make a ton of really basic mistakes.

The Unicode standard weighs probably ten pounds. Even just an overview of it would have to discuss the subtle distinctions between characters, glyphs, codepoints, etc. Now think about ASCII. It's 128 characters. I can explain the entire thing to someone that knows binary in about 5 minutes.

I believe that almost all software should be written with full Unicode support these days, but it's been a long road to achieving a truly international character set with encoding to suit a variety of purposes, and it's not over just yet.

Solution 5 - Unicode

Laziness, ignorance.

Solution 6 - Unicode

One huge factor is programming language support, most of which use a character set that fits in 8 bits (like ASCII) as the default for strings. Java's String class uses UTF-16, and there are others that support variants of Unicode, but many languages opt for simplicity. Space is so trivial of a concern these days that coders who cling to "space efficient" strings should be slapped. Most people simply aren't running on embedded devices, and even devices like cell phones (the big computing wave of the near future) can easily handle 16-bit character sets.

Another factor is that many programs are written only to run in English, and the developers (1) don't plan (or even know how) to localize their code for multiple languages, and (2) they often don't even think about handling input in non-Roman languages. English is the dominant natural language spoken by programmers (at least, to communicate with each other) and to a large extent, that has carried over to the software we produce. However, the apathy and/or ignorance certainly can't last forever... Given the fact that the mobile market in Asia completely dwarfs most of the rest of the world, programmers are going to have to deal with Unicode quite soon, whether they like it or not.

For what it's worth, I don't think the complexity of the Unicode standard is not that big of a contributing factor for programmers, but rather for those who must implement language support. When programming in a language where the hard work has already been done, there is even less reason to not use the tools at hand. C'est la vie, old habits die hard.

Solution 7 - Unicode

All operating systems until very recently were built on the assumption that a character was a byte. It's APIs were built like that, the tools were built like that, the languages were built like that.

Yes, it would be much better if everything I wrote was already... err... UTF-8? UTF-16? UTF-7? UTF-32? Err... mmm... It seems that whatever you pick, you'll annoy someone. And, in fact, that's the truth.

If you pick UTF-16, then all of your data, as in, pretty much the western world whole economy, stops being seamlessly read, as you lose the ASCII compatibility. Add to that, a byte ceases to be a character, which seriously break the assumptions upon which today's software is built upon. Furthermore, some countries do not accept UTF-16. Now, if you pick ANY variable-length encoding, you break some basic premises of lots of software, such as not needing to traverse a string to find the nth character, of being able to read a string from any point of it.

And, then UTF-32... well, that's four bytes. What was the average hard drive size or memory size but 10 years ago? UTF-32 was too big!

So, the only solution is to change everything -- software, utilites, operating systems, languages, tools -- at the same time to be i18n-aware. Well. Good luck with "at the same time".

And if we can't do everything at the same time, then we always have to keep an eye out for stuff which hasn't been i18n. Which causes a vicious cycle.

It's easier for end user applications than for middleware or basic software, and some new languages are being built that way. But... we still use Fortran libraries written in the 60s. That legacy, it isn't going away.

Solution 8 - Unicode

Because UTF-16 became popular before UTF-8 and UTF-16 is a pig to work with. IMHO

Solution 9 - Unicode

Because for 99% of applications, Unicode support is not a checkbox on the customer's product comparison matrix.

Add to the equation:

  1. It takes a conscious effort with almost no readily visible benefit.
  2. Many programmers are afraid of it or don't understand it.
  3. Management REALLY doesn't understand it or care about it, at least not until a customer is screaming about it.
  4. The testing team isn't testing for Unicode compliance.
  5. "We didn't localize the UI, so non-English speakers wouldn't be using it anyway."

Solution 10 - Unicode

Tradition and attitude. ASCII and computers are sadly synonyms to many people.

However, it would be naïve to think that the rôle of Unicode, is only a matter of Exotic languages from Eurasia and other parts of the world. A rich text encoding has lots of meaning to bring even to a "plain" English text. Look in a book sometime.

Solution 11 - Unicode

I would say there are mainly two reason. First one is simply that the Unicode support of your tools just isn't up to snuff. C++ still doesn't have Unicode support and won't get it until the next standard revision, which will take maybe a year or two to be finished and then another five or ten years to be in widespread use. Many other languages aren't much better and even if you finally have Unicode support, it might still be a more cumbersome to use then plain ASCII strings.

The second reason is in part what it causing the first issue, Unicode is hard, its not rocket science, but it gives you a ton of problems that you never had to deal with in ASCII. With ASCII you had a clear one byte == one glyph relationships, could address the Nth character of a string by a simple str[N], could just store all characters of the whole set in memory and so on. With Unicode you no longer can do that, you have to deal with different ways Unicode is encoded (UTF-8, UTF-16, ...), byte order marks, decoding errors, lots of fonts that have only a subset of characters which you would need for full Unicode support, more glyphs then you want to store in memory at a given time and so on.

ASCII could be understand by just looking at an ASCII table without any further documentation, with Unicode that is simply no longer the case.

Solution 12 - Unicode

Because of the inertia caused by C++. It had (has) horrible unicode support and dragged back the developers.

Solution 13 - Unicode

I personally do not like how certain formats of unicode break it so that you can no longer do string[3] to get the 3rd character. Sure it could be abstracted out, but imagine how much slower a big project with strings, such as GCC would be if it had to transverse a string to figure out the nth character. The only option is caching where "useful" positions are and even then it's slow, and in some formats your now taking a good 5 bytes per character. To me, that is just ridiculous.

Solution 14 - Unicode

More overhead, space requirements.

Solution 15 - Unicode

I suspect it's because software has such strong roots in the west. UTF-8 is a nice, compact format if you happen to live in America. But it's not so hot if you live in Asia. ;)

Solution 16 - Unicode

Unicode requires more work (thinking), you usually only get paid for what is required so you go with the fastest less complicated option.

Well that's from my point of view. I guess if you expect code to use std::wstring hw(L"hello world") you have to explain how it all works that to print wstring you need wcout : std::wcout << hw << std::endl; (I think), (but endl seems fine ..) ... so seems like more work to me - of course if I was writing international app I would have to invest into figuring it out but until then I don't (as I suspect most developers).

I guess this goes back to money, time is money.

Solution 17 - Unicode

It's simple. Because we only have ASCII characters on our keyboards, why would we ever encounter, or care about characters other than those? It's not so much an attitude as it is what happens when a programmer has never had to think about this issue, or never encountered it, perhaps doesn't even know what unicode is.

edit: Put another way, Unicode is something you have to think about, and thinking is not something most people are interested in doing, even programmers.

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
QuestionbaudtackView Question on Stackoverflow
Solution 1 - UnicodeNicolas DumazetView Answer on Stackoverflow
Solution 2 - Unicodeuser34411View Answer on Stackoverflow
Solution 3 - UnicodeEricView Answer on Stackoverflow
Solution 4 - UnicodePeterAllenWebbView Answer on Stackoverflow
Solution 5 - UnicodeMatthew OlenikView Answer on Stackoverflow
Solution 6 - UnicodeQuinn TaylorView Answer on Stackoverflow
Solution 7 - UnicodeDaniel C. SobralView Answer on Stackoverflow
Solution 8 - UnicodePeter EricsonView Answer on Stackoverflow
Solution 9 - UnicodeJohnFxView Answer on Stackoverflow
Solution 10 - Unicodeu0b34a0f6aeView Answer on Stackoverflow
Solution 11 - UnicodeGrumbelView Answer on Stackoverflow
Solution 12 - UnicodeAndrei RîneaView Answer on Stackoverflow
Solution 13 - UnicodeEarlzView Answer on Stackoverflow
Solution 14 - UnicodeCugaView Answer on Stackoverflow
Solution 15 - UnicodePeter RudermanView Answer on Stackoverflow
Solution 16 - UnicodestefanBView Answer on Stackoverflow
Solution 17 - UnicodeBretonView Answer on Stackoverflow