Bug #1839: String#tr borked for UTF-8 0080..00FF
http://redmine.ruby-lang.org/issues/show/1839

Author: Brian Candler
Status: Open, Priority: Normal
ruby -v: ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]

>> a = "uber"
=> "uber"
>> a.encoding
=> #<Encoding:UTF-8>
>> b = a.tr("u","ΓΌ")
=> "\xFCber"
>> b.encoding
=> #<Encoding:UTF-8>

What's more remarkable,

>> b.valid_encoding?
=> true

!!!

>> b << "x"
=> "\xFCberx"
>> b.valid_encoding?
=> true

!!!

And yet it works for codepoints > 255:

>> c = a.tr("u","??")
=> "??ber"
>> c.encoding
=> #<Encoding:UTF-8>
>>


----------------------------------------
http://redmine.ruby-lang.org