Mitch Tishmack <idylls / gmail.com> wrote:

> I have a minor problem with a utf8 string.
>
> In short I see this behavior:
>
> "Stuhlu".sub(/u/,'üÊ)
> => "Stlu"
> "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  #=> "hutS"

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

-Levin