ruby-changes:33359
From: nobu <ko1@a...>
Date: Wed, 26 Mar 2014 20:14:50 +0900 (JST)
Subject: [ruby-changes:33359] nobu:r45438 (trunk): encoding.c: fix encoding of dynsym
nobu 2014-03-26 20:14:44 +0900 (Wed, 26 Mar 2014) New Revision: 45438 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45438 Log: encoding.c: fix encoding of dynsym * encoding.c (rb_enc_get_index): the encoding of dynamic symbol comes from fstr. Modified files: trunk/encoding.c trunk/test/ruby/test_encoding.rb Index: encoding.c =================================================================== --- encoding.c (revision 45437) +++ encoding.c (revision 45438) @@ -747,6 +747,9 @@ rb_enc_get_index(VALUE obj) https://github.com/ruby/ruby/blob/trunk/encoding.c#L747 obj = rb_id2str(SYM2ID(obj)); } switch (BUILTIN_TYPE(obj)) { + case T_SYMBOL: + obj = RSYMBOL(obj)->fstr; + /* fall through */ as_default: default: case T_STRING: Index: test/ruby/test_encoding.rb =================================================================== --- test/ruby/test_encoding.rb (revision 45437) +++ test/ruby/test_encoding.rb (revision 45438) @@ -110,6 +110,7 @@ class TestEncoding < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_encoding.rb#L110 bin = "\xff".force_encoding(Encoding::ASCII_8BIT).to_sym asc = "b".force_encoding(Encoding::ASCII_8BIT) assert_equal(Encoding::ASCII_8BIT, Encoding.compatible?(bin, asc)) + assert_equal(Encoding::UTF_8, Encoding.compatible?("\u{3042}".to_sym, ua.to_sym)) end def test_errinfo_after_autoload -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/