* string.c (String#dump): Change escaping of non-ASCII characters in

UTF-8 to use upper-case four-digit hexadecimal escapes without braces
  where possible [Feature #12419].
* test/ruby/test_string.rb (test_dump): Add tests for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
duerst 2016-07-22 08:13:38 +00:00
parent 21269d37a1
commit c6692d9410
3 changed files with 31 additions and 4 deletions

View file

@ -614,6 +614,18 @@ CODE
def test_dump
a= S("Test") << 1 << 2 << 3 << 9 << 13 << 10
assert_equal(S('"Test\\x01\\x02\\x03\\t\\r\\n"'), a.dump)
b= S("\u{7F}")
assert_equal(S('"\\x7F"'), b.dump)
b= S("\u{AB}")
assert_equal(S('"\\u00AB"'), b.dump)
b= S("\u{ABC}")
assert_equal(S('"\\u0ABC"'), b.dump)
b= S("\uABCD")
assert_equal(S('"\\uABCD"'), b.dump)
b= S("\u{ABCDE}")
assert_equal(S('"\\u{ABCDE}"'), b.dump)
b= S("\u{10ABCD}")
assert_equal(S('"\\u{10ABCD}"'), b.dump)
end
def test_dup