I was quite depressed listening to Tim Bray talk about Unicode and Ruby at RubyConf. While Tim did a wonderful job at explaining the problems, he didn’t really provide much in the way of a solution. Which is why I was quite happy when I read Julian Tarkhanov’s slide deck from his Unicode presentation at the Rails Show and Tell meeting in Amerstam where he introduces his Unicode hacks libraries.
I really like his idea about using an accessor proxy on String:
name = 'Claus Müller' puts name.reverse #=> rell??M sualC name.length #=> 13 puts name.chars.reverse #=> rellüM sualC name.chars.length #=> 12
Notice how accessing the same string via the chars accessor correctly reverses the German string.