Easier Unicode support in Rails (and eventually Ruby?)
The guys over at Fingertips present an article entitled 'excellent and pragmatic proposal for easier Unicode support in Rails'. Julian 'Julik' Tarkhanov has developed a proxy class for String that tweaks all of the methods to work properly with Unicode. You can then use code like this:
text.chars.length > length ? text.chars[0...l] + truncate_string : text
chars provides the proxy object from the text string. You can also use code like text.u.length
as chars is aliased to u too.
They want to see it accepted as a patch to Rails, although I'm personally more interested in seeing this become a gem and be available in Ruby generally. Undoubtedly it'd be easy to extract, but once an official version comes along, it'll be excellent.
June 16, 2006 at 9:42 pm
Just to clarify this, we at Fingertips did not actually develop the proxy class, it was developed by Julian 'Julik' Tarkhanov. We just think it's really an excellent and pragmatic proposal for easier Unicode support. :-)
June 16, 2006 at 9:45 pm
Oh, okay, I got the impression he was related to you. Thanks, I'll fix the post now :)
June 17, 2006 at 4:18 am
Oh hells yes. Nice, transparent stop-gap measure until Matz finally drops the Unicode bomb on 1.9, or 2.0, or RSN.
Dropping it out to a gem wouldn't take that much effort, either. Just extract what he's using of ActionPack (because seriously--who doesn't love ActionPack?) and you're off to the races.
Can't wait to see how this shakes out. If it's stable and doesn't slow things down much, Core would have to be drunk not to fold this into Rails. I mean, talking about Unicode has always been a great way to get any Rubyist to cry.