Project

General

Profile

Bug #1839

String#tr borked for UTF-8 0080..00FF

Added by candlerb (Brian Candler) over 11 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
Backport:
[ruby-core:24612]

Description

=begin

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

=end

Also available in: Atom PDF