1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

encoding.c: fix encoding of dynsym

* encoding.c (rb_enc_get_index): the encoding of dynamic symbol
  comes from fstr.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-03-26 11:14:44 +00:00
parent 2d8c3e7851
commit e8de850e6d
2 changed files with 4 additions and 0 deletions

View file

@ -747,6 +747,9 @@ rb_enc_get_index(VALUE obj)
obj = rb_id2str(SYM2ID(obj));
}
switch (BUILTIN_TYPE(obj)) {
case T_SYMBOL:
obj = RSYMBOL(obj)->fstr;
/* fall through */
as_default:
default:
case T_STRING:

View file

@ -110,6 +110,7 @@ class TestEncoding < Test::Unit::TestCase
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