"Warren Brown" <WBrown / isoft.com> schrieb im Newsbeitrag
news:4962B73AD3A1704FA415C8E7A07740350192CC9E / isoftmail01...
> Ara,
>
> > something like this
> >
> >   ~ > cat b.rb
> >   class String
> >     def chars width = 1
> >       unpack "a#{ width }" *  (size / width + (size % width == 0 ? 0 :
> 1))
> >     end
> >   end
>
>     I wish it were that easy, but multi-byte character sets are not
> always fixed-width.  For example, UTF-8 characters can be anywhere from
> one byte to (theoretically) six bytes long.  So the multi-byte handling
> would have to be a little more sophisticated.

I'd suggest these two changes:

 - have chars accept an encoding and yield some std char type (which we
might have to add to ruby)
 - don't make it return an array, instead iterate.  That's more efficient if
only a iteration has to be done

Regards

    robert