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. Read More