4 ms·
It replaces one set of quirky hacks for a different set, just in different parts of your code. So in a way it's no worse. I have to say I was sceptical of Ruby
by hetman 9y ago
It replaces one set of quirky hacks for a different set, just in different parts of your code. So in a way it's no worse.
I have to say I was sceptical of Ruby 1.9's new approach to Unicode thinking Python 3.0's approach looked much cleaner. It does on paper. In practice though, I have to admit I get where Ruby was going with it all now.
- Something1234 9y agoWhats the difference between the approaches?
- int_19h 9y agoIn Python 3, all strings are Unicode, period. When you need a sequence of bytes that's something else, there's a separate types for that (called, unsurprisingly, "bytes"). If you need to treat it as a string, you use the decode() method and pass the encoding should be used to interpret it. If you need to get byes out of a string, it's the reverse process - you call encode(), and, again, specify the encoding. In Ruby, strings are byte sequences with encoding attached. Unicode is not special - it's just one of many available encodings. And different strings in the program can have different encodings. This makes it possible to represent data richer than what Unicode allows (e.g. the various East Asian encodings that avoid CJK unification issues). But it also means that it might be impossible to e.g. concatenate two random strings, or even compare them for equality in a meaningful way, because their encodings are incompatible.
- hyperbovine 9y agoI wonder if this has anything to do with Matz being Japanese. I do my best to avoid Unicode at all costs because as a native English speaker ASCII was working out great for me.
- derefr 9y agoEven if you're only shipping to an English-speaking US audience, people are still going to be throwing Unicode at your app. One word: emojis.
- alphaalpha101 9y agoEmojis are utterly stupid and should never have been added to Unicode. They are not human language, at all.
- makapuf 9y agoTouché.
- stordoff 9y agoIt was working fine for me, right up to the point I wrote an article that contained "naïve", at which point my naïve string handling (SQLite->HTML) broke horribly. Moving to Python3/Unicode was the easiest solution.