I have a utf8 string that I need to truncate, but I want to obviously make sure it is truncated at a character boundary. s.slice does not ensure that. Is there a clean fast way to do that?
s.mb_chars.slice Please ask questions like these on the rubyonrails-talk list the next time, this list is for development of the framework itself. Cheers, Eloy On Jul 13, 2009, at 10:30 AM, Alex wrote:> > I have a utf8 string that I need to truncate, but I want to obviously > make sure it is truncated at a character boundary. > > s.slice does not ensure that. > > Is there a clean fast way to do that? > > >
Understood. Solved anyway - s.mb_chars.slice(..) On Jul 13, 1:32 am, Eloy Duran <eloy.de.en...@gmail.com> wrote:> s.mb_chars.slice > > Please ask questions like these on the rubyonrails-talk list the next > time, this list is for development of the framework itself. > > Cheers, > Eloy > > On Jul 13, 2009, at 10:30 AM, Alex wrote: > > > > > I have a utf8 string that I need to truncate, but I want to obviously > > make sure it is truncated at a character boundary. > > > s.slice does not ensure that. > > > Is there a clean fast way to do that? > >