How to make locale aware uppercase operation?
Standard tr '[:lower:]' '[:upper:]' trick doesn't work:
=$ echo żółw | tr "[:lower:]" "[:upper:]"
żółW
(it should be ŻÓŁW)
I'd rather avoid having to run Perl or anything such heavy-weight.
How to make locale aware uppercase operation?
Standard tr '[:lower:]' '[:upper:]' trick doesn't work:
=$ echo żółw | tr "[:lower:]" "[:upper:]"
żółW
(it should be ŻÓŁW)
I'd rather avoid having to run Perl or anything such heavy-weight.
It seems to me that if you want to avoid a heavyweight you'd need to provide the characters yourself, and, given that's a nonstarter for a truly generic solution, you are stuck with using a heavyweight.
One heavyweight solution
vinko@parrot:~$ more t.py
# coding: UTF-8
print unicode.upper("żółw".decode('utf-8'))
vinko@parrot:~$ python t.py
ŻÓŁW
Non-heavyweight solution that would require you to specify each character
vinko@parrot:~$ echo żół | tr "[żół]" "[ŻÓŁ]"
ŻÓŁ
EDIT: Based on the other answer and comments, BASH 4.0 IS locale sensitive and aware of wide chars. You have to set a proper locale of course (LC_CTYPE or LC_ALL) so BASH can tell what it is supposed to do. Also it seems that there are locale sensitive versions of tr as of late (for example, Mac OSX 10.6)
If you bash is new enough, it may be able to do it (see bash-4.0 NEWS item 1.hh.).
bash -c 'foo="żółw"; echo ${foo^^}'
zsh, too (since 4.3.3?):
zsh -c 'foo="żółw"; echo ${(U)foo}'