Project

General

Profile

Actions

Bug #1192

closed

encoding problem with tr() and hash keys 1.9.1

Added by do1 (Do One) about 15 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
Backport:
[ruby-core:22326]

Description

=begin
In utf-8 environment I do:

irb(main):121:0> h = {"a" => 1, "\u0101" => 2}
=> {"a"=>1, "ā"=>2}
irb(main):122:0> h.key? "a".tr("z", "\u0101")
=> false <--- wrong!
irb(main):123:0> h.key? "\u0101".tr("z", "\u0101")
=> true

So after I change utf-8 string without extended chars in it with tr(),
where second character set is having extended chars, new string is not
found in hash.

Both strings are same in Marshal encoding:

irb(main):124:0> Marshal.dump "a".tr("\u0101", "\u0101")
=> "\x04\bI"\x06a\x06:\rencoding"\nUTF-8"
irb(main):126:0> Marshal.dump "a"
=> "\x04\bI"\x06a\x06:\rencoding"\nUTF-8"
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0