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

* parse.y (parser_str_new): encoding of UTF-8 literal string in

US-ASCII script is UTF-8. [ruby-dev:33406]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2008-01-28 02:26:23 +00:00
parent c7c263eefc
commit 4a94863244
3 changed files with 7 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Mon Jan 28 11:24:49 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* parse.y (parser_str_new): encoding of UTF-8 literal string in
US-ASCII script is UTF-8. [ruby-dev:33406]
Mon Jan 28 10:25:59 2008 NAKAMURA Usaku <usa@ruby-lang.org> Mon Jan 28 10:25:59 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* test/ruby/test_m17n.rb (test_magic_comment): add test. * test/ruby/test_m17n.rb (test_magic_comment): add test.

View file

@ -4848,7 +4848,7 @@ parser_str_new(const char *p, long n, rb_encoding *enc, int func, rb_encoding *e
if (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT) { if (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT) {
rb_enc_associate(str, rb_usascii_encoding()); rb_enc_associate(str, rb_usascii_encoding());
} }
else if (enc0 == rb_usascii_encoding()) { else if (enc0 == rb_usascii_encoding() && enc != rb_utf8_encoding()) {
rb_enc_associate(str, rb_ascii8bit_encoding()); rb_enc_associate(str, rb_ascii8bit_encoding());
} }
} }

View file

@ -153,6 +153,7 @@ class TestM17N < Test::Unit::TestCase
def test_utf8_literal def test_utf8_literal
assert_equal(Encoding::UTF_8, "\u3042".encoding, "[ruby-dev:33406] \"\\u3042\".encoding") assert_equal(Encoding::UTF_8, "\u3042".encoding, "[ruby-dev:33406] \"\\u3042\".encoding")
assert_raise(SyntaxError) { eval(a('\u3052\x80')) }
end end
def test_string_mixed_unicode def test_string_mixed_unicode