Mitch Tishmack <idylls / gmail.com> wrote:

> I have a minor problem with a utf8 string.
>
> In short I see this behavior:
>
> "Stuhlu".sub(/u/,'?')
> => "St?hlu"
> "Stuhlu".reverse.sub(/u/,'?').reverse
> => "Stuhl\274\303"
> "Stuhlu".reverse.sub(/u/,'?').split(//).reverse.join
> => "Stuhl?"

You could do this:

   $KCODE = 'u'
   class String
     def reverse; self.scan(/./).reverse.join end
   end

   "Stuhl?".reverse  #=> "?lhutS"

found on  
<http://redhanded.hobix.com/inspect/closingInOnUnicodeWithJcode.html>

-Levin