[ruby-core:22326] [Bug #1192] encoding problem with tr() and hash keys 1.9.1

12 views
Skip to first unread message

Do One

unread,
Feb 22, 2009, 4:33:21 AM2/22/09
to ruby...@ruby-lang.org
Bug #1192: encoding problem with tr() and hash keys 1.9.1
http://redmine.ruby-lang.org/issues/show/1192

Author: Do One
Status: Open, Priority: Normal
Target version: 1.9.1
ruby -v: ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]

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"


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

Nobuyoshi Nakada

unread,
Feb 22, 2009, 5:26:36 AM2/22/09
to ruby...@ruby-lang.org
Issue #1192 has been updated by Nobuyoshi Nakada.

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r22525.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1192

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

Yusuke Endoh

unread,
Feb 22, 2009, 7:47:34 AM2/22/09
to ruby...@ruby-lang.org
Issue #1192 has been updated by Yusuke Endoh.

Category set to M17N
Status changed from Closed to Open
Assigned to set to Yui NARUSE

Hi,

The fix in r22525 seems to be incomplete:

$ ruby19 -ve 'p ["a".hash, "a".tr("a", "\u0101").tr("\u0101", "a").hash]'
ruby 1.9.2dev (2009-02-22 trunk 22527) [i686-linux]
[903321233, 903321232]

--
Yusuke ENDOH <ma...@tsg.ne.jp>

Nobuyoshi Nakada

unread,
Feb 22, 2009, 8:46:34 AM2/22/09
to ruby...@ruby-lang.org
Issue #1192 has been updated by Nobuyoshi Nakada.

Status changed from Open to Closed

Applied in changeset r22547.

Reply all
Reply to author
Forward
0 new messages