15 ms·
Unicode is, in 2012, still “cutting edge.”
- a2tech 14y agoThats because Unicode is STILL a pain to use. I read the articles that come along about Unicode and still don't understand why handling it is so impossible. Until its transparent for a programmer to use, it won't be as widely used as it should. My apps (and I'm ashamed to admit it) aren't Unicode friendly. But its too much work currently for too little reward to go through and make all that code Unicode friendly.
- sp332 14y agoWho even makes a UTF-8 implementation that can't handle UTF-8? Unfortunately, having dealt with mysql libs lately, I don't doubt that at all. That said, if you think Unicode is a pain, try storing and retrieving "𝒜" in any other encoding. I'll stick to Unicode, thanks. :)
- aidenn0 14y agoI've had very few issues making programs I've written unicode friendly, but then I gave up on MySQL about a decade ago. The only real issue is handling bad input, as you never get an error with decoding e.g. ISO-8859-1; for a lot of applications you need to handle potentially malicious input, so you can do it there, but even for trusted input, there is a lot of really-broken external programs that output "UTF-8" or "UTF-16" (scare quotes intentional). I really think a lot of the problems with unicode is that a lot of languages/libraries try to handle it transparently, and that just doesn't work; encoding/decoding is part of dealing with external formats, and trying to do it transparently means that it will fail unexpectedly.
- henrikschroder 14y ago> Thats because Unicode is STILL a pain to use. I think that depends heavily on what programming language and frameworks you are using.
- jpdoctor 14y agoPointers to a comparison across languages would be welcomed. TIA.
- arnsholt 14y agoTom Christiansen's talk Unicode: The good, the bad, & the (mostly) ugly covers a lot of Unicode wrinkles and how Javascript, PHP, Go, Python, Ruby, Java, and Perl handles them. Slides for that talk and two other Perl-related Unicode talks are at http://training.perl.com/OSCON2011/index.html http://training.perl.com/OSCON2011/index.html
- LoonyPandora 14y agohttp://training.perl.com/OSCON2011/index.html http://training.perl.com/OSCON2011/index.html Specifically the talk titled "Unicode Support Shootout: The Good, The Bad, & the (mostly) Ugly" It's a year old now, but it's still relevant. It gives a very detailed look at unicode support across JavaScript, PHP, Go, Ruby, Python, Java, and Perl.
- BenSS 14y agoThe root of it is that most things still assume ASCII, etc by default. I griped about this a while ago, as a whole, we should be moving all our tools to being UTF-8 by default, and ASCII being the 'odd' case instead of the other way around!
- rwallace 14y agoImplementing the display, collation or suchlike manipulation of Unicode text isn't feasible for the nonspecialist, to be sure (in practice that means you call an appropriate library/framework/API and hope they got it right). But storing a stream of UTF-8 and retrieving it on command is not remotely difficult. You almost have to go out of your way to screw that up.
- rwallace 14y agoImplementing the display, collation or suchlike manipulation of Unicode text isn't feasible for the nonspecialist, to be sure (in practice that means you call an appropriate library/framework/API and hope they got it right). But storing a stream of UTF-8 and retrieving it on command is not remotely difficult. You almost have to go out of your way to screw that up.
- wmf 14y agoIt looks like we're still seeing fallout from the "16 bits are all you need" thing. Maybe telling people that they'd never need to worry about this stuff after adopting (BMP subset of) UTF-8 wasn't a great idea.
- deleted 14y ago[deleted]
- derleth 14y ago> (BMP subset of) UTF-8 The hell of it is, UTF-8 expands gracefully to the astral planes; it's UTF-16 that you need to worry about, either because the people designing the software never heard of surrogate pairs, in which case they didn't give you UTF-16 but UCS-2, or implemented surrogate pairs incorrectly.
- VMG 14y ago> MySQL’s utf8 encoding only covers the BMP. It can’t handle 4-byte characters at all. Wow. That is pathetic.
- excuse-me 14y agoNo it's engineering. Here are two versions of the software. 1, is faster, better tested and string handling (it's a database!) is much faster but it only handles the 65000 most common characters 2, this one can handle upside down characters from a 1930s paper on formal logic in Turkish. But is slower for all other cases and we haven't really tested it as much,. Do you have a redundant,self powered , asteroid impact proof internet connection? No? Pathetic !
- pindi 14y agoSure, in some cases it makes sense to make the tradeoff of not handling more obscure characters. But if the tradeoff is made, the encoding should not be called UTF-8. "UTF-8 (UCS Transformation Format—8-bit[1]) is a variable-width encoding that can represent every character in the Unicode character set," says Wikipedia. The UTF-8 implementation in MySQL does not meet this definition because it cannot represent every character in the Unicode character set.
- wmf 14y agoWhen MySQL first implemented UTF-8 they probably did support every Unicode character... because there were less than 64K Unicode characters. Then Unicode/UTF-8 was redefined out from under them.
- quink 14y ago> there were less than 64K Unicode characters. Then Unicode/UTF-8 was redefined out from under them. Unicode 2.0 introduced multiple planes, i.e. more than 65536 characters. That was in 1996. If that was the case, then MySQL has had more than one-and-a-half decades to introduce multiple planes and seems to have done so less than a year ago. I disagree with being 'redefined out from under them', when it was defined a year after MySQL started, at a time when it probably didn't even have Unicode support yet anyway.
- mrj 14y agoThis is a MySQL limitation that they have fixed in recent releases (as the OP notes). It's not fair to blame Unicode at large for MySQL problems. However, it's true that Unicode is (relatively speaking) very new for such a fundamental technology. Support in applications still varies widely. I wouldn't characterize it as cutting edge though, since we have many mainstream programming languages built using Unicode internally.
- masklinn 14y ago> This is a MySQL limitation that they have fixed in recent releases (as the OP notes) TFA notes that this is not fixed, the `utf-8` mysql encoding still isn't utf-8. And as TFA also notes related technologies (aka drivers) may not be compatible with it (the example he uses, mysql2 for Ruby, still hasn't had an official release supporting utf8mb4[0]) > it's true that Unicode is (relatively speaking) very new for such a fundamental technology That's becoming quite hard an argument to swallow when encountering astral planes issues in 2012 when Unicode 2.0 was introduced in 1996. [0] https://github.com/brianmario/mysql2/issues/249 https://github.com/brianmario/mysql2/issues/249
- mrj 14y ago> > it's true that Unicode is (relatively speaking) very new for such a fundamental technology > That's becoming quite hard an argument to swallow when encountering astral planes issues in 2012 when Unicode 2.0 was introduced in 1996. I don't get your argument. MySQL was also released around that time and we don't call it "cutting edge" because we found a bug. There are bugs in old stuff all the time but (most) people don't throw a fit.
- pyre 14y agoUnicode is being called 'cutting edge' because it's no longer 'old hat.' Lots of things claim support for Unicode, but few (or none) support it well. Unicode isn't a software project, it's a spec/idea. It's like calling a Star Trek tricorder "cutting edge" because no one has implemented a fully-functional version. Sure the idea has been around for a while, but at this point there's no acceptable manifestations of that idea.
- peteretep 14y agoThis particular limitation of MySQL hit me HARD HARD HARD circa 2008 when I tried to use some of that upside down text you find online as test data, and just couldn't work out why I was getting data corruption. Luckily Perl's Unicode support is fantastic, and saved my ass
- postfuturist 14y agoHow did you solve MySQL's unicode limitations with Perl?
- lmm 14y agoAt my previous^2 company we worked around MySQL's limitations by just storing our data in VARBINARY columns, encoded as utf8 on the client-side. Worked like a charm. (I hate MySQL)
- dunham 14y agoApple's "textedit" can't open files with these characters in them. It reports "The document “test.txt” could not be opened. Text encoding Unicode (UTF-8) isn’t applicable."
- Ralith 14y ago"Isn't applicable?" What kind of an error message is that?
- lambda 14y agoWorks fine for me. What version of Mac OS X/TextEdit are you using? Are you sure you are saving it (and opening it) as UTF-8?
- dunham 14y agoSorry, my mistake. I was saving a file from textmate with the string "𝖙𝖊𝖘𝖙" in it and then opening with "open -a textedit eg.txt". The same experiment with cat in place of textmate works fine, so it's textmate that is buggy. According to "od -x1", textmate is writing: 0000000 ed a0 b5 ed b6 99 ed a0 b5 ed b6 8a ed a0 b5 ed 0000020 b6 98 ed a0 b5 ed b6 99 So textedit is right to complain.
- lambda 14y agoYeah, looks like Textmate is simply running the UTF-8 algorithm over UTF-16 code units, so each surrogate is being turned into a single UTF-8 code unit (which decodes to an invalid character). It turns out that this is such a common mistake that there's even a name for this encoding, CESU-8: http://en.wikipedia.org/wiki/CESU-8 http://en.wikipedia.org/wiki/CESU-8
- timr 14y agoYeah, well, Unicode is hard. If it looks simple, it's only because you haven't looked carefully enough: http://www.unicode.org/versions/Unicode6.1.0/ http://www.unicode.org/versions/Unicode6.1.0/ The latest published version of the standard (5.0) runs to almost 1500 pages: http://www.unicode.org/book/aboutbook.html http://www.unicode.org/book/aboutbook.html (Best quote from that page: “Hard copy versions of the Unicode Standard have been among the most crucial and most heavily used reference books in my personal library for years.” -- Donald Knuth) People think that Unicode support is just a matter of implementing multi-byte characters, but it's so much more: you've got collation rules, ligatures, rendering, line-breaking, punctuation, reading direction, and so on. Any technical standard that aims to cover all known human languages is going to be a little bit complex.
- koenigdavidmj 14y ago> People think that Unicode support is just a matter of implementing multi-byte characters, but it's so much more: you've got collation rules, ligatures, rendering, line-breaking, punctuation, reading direction, and so on. Any technical standard that aims to cover all known human languages is going to be a little bit complex. Half of those are irrelevant to MySQL or any other database. Those are front end problems. Even reading punctuation, text direction, and the like will only be important in more advanced collation orders (as opposed to just binary ordering, which he was using).
- timr 14y agoIt's true that glyph rendering won't matter to a database store, and that binary collation is "good enough" for most people (but then again, "good enough" is how you get to a UTF-8 implementation that doesn't support 4-byte characters). That said, it's also true that Unicode characters outside of the BMP are still pretty exotic/specialized: http://stackoverflow.com/questions/5567249/what-are-the-most-common-non-bmp-unicode-characters-in-actual-use http://stackoverflow.com/questions/5567249/what-are-the-most... Is it "excusable" that MySQLs implementation of UTF-8 isn't standard? That's a judgment call (they are up-front about it in the docs). But given that most unicode characters "in the wild" lie in the BMP, I can see how they'd make that trade-off. There might well be a technical limitation lurking somewhere in the database internals that made 4-byte characters a problem.
- joelhaasnoot 14y agoUnicode is just plain hard to do right... I worked on a product for a couple of months geared at minority languages in developing countries - doing linguistics work etc. It was a pain to support Unicode, because there's lots of code points, lots of weird cases (what's capital?), ICU is a good lib but it's not up to date to the latest Unicode version and it's C/C++ (and thus a pain in C#). Oh, and there's the Private Use Area where characters go while Unicode decides to include them or not...
- soc88 14y agoEspecially annoying are those people who think the transformations formats are all of Unicode (and consequently suggest to use UTF-32 "to solve all problems").
- chadrs 14y agoYou don't even want to know the hack I had to implement to get non-BMP characters stored in MySQL 5.1 'utf8' column.
- pjscott 14y agoThat's exactly why I use the default ISO-8859-1 encoding for all my MySQL tables, try to only stick ASCII into it, and store any Unicode text as binary UTF-8, encoded client-side. It's stupid and shouldn't be necessary, but at least MySQL can't screw it up.
- antihero 14y agoIf we're using PostgreSQL is everything going to be pretty much dandy?
- ocharles 14y agoAs long as your clusters use the right locale/encoding settings, yes.
- justincormack 14y agoOnly use a locale that does unicode collation if you need to, as it is a big performance hit.
- jeltz 14y agoYes, the PostgreSQL developers would never allow commit something which silently truncates perfectly valid text.
- losethos 14y agoASCII should die and all source code and tools should be unicode. Everything should be clean, like nothing but unicode ever existed. That's how it should be for the next 1000 years or until English kills-off all other languages. God says... C:\Text\BIBLE.TXT ne cannot be able to see the earth: and they shall eat the residue of that which is escaped, which remaineth unto you from the hail, and shall eat every tree which groweth for you out of the field: 10:6 And they shall fill thy houses, and the houses of all thy servants, and the houses of all the Egyptians; which neither thy fathers, nor thy fathers' fathers have seen, since the day that they were upon the earth unto this day. And he turned himself, and went out from Pharaoh. 10:7 And Pharaoh's se
- PaulHoule 14y agoit's almost scandalous how poorly Unicode has been implemented in the most popular development platforms. Java, for instance, implemented 2-byte encoding and uses surrogates for the higher planes, which means you get the worst of both worlds... You double the size of ASCII text (that is, half the speed of bandwidth-limited operations on text) and you've still got a variable length encoding... but you've got lots of methods and user-written code that assume that the text is fixed length encoded. what a mess
- krollew 14y agoYeah, so what? UTF-8 is Linux standard. I use it, probably most of web use it(where needed). Why I don't see problems with it in software I use and on the web? I can't remember when I had any problem with UTF-8 last time.
- tezza 14y agoMan, I still find myself reaching for dos2unix all the time. How sad.
- webreac 14y agoThese 16bits, UCS, wide char ideas are just plain wrong ! Just use UTF-8 for the files and for communication and 32bits code points internally when needed.