Turkish Is Crazy

So I was working on a very odd bug at work. For some reason, printing didn’t work when you chose Turkish as your language.

After some digging, I discovered that Turkish is very odd in one particular aspect. The wikipedia entry about it can explain better than me, but suffice to say:

$ LANG=en_US.UTF-8 python -c "import locale; locale.setlocale(locale.LC_ALL, ''); print 'TURKISH'.lower()"
$ LANG=tr_TR.UTF-8 python -c "import locale; locale.setlocale(locale.LC_ALL, ''); print 'TURKISH'.lower()"

This has implications for all sorts of sloppily written code. Normally it works alright, if all you care about is if two strings are the same thing when lower‘ed, but if you are using lower as part of a hash function and then talking over a network, everything will screw up. I’m surprised anything works in Turkish.