summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-17 22:29:51 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-17 22:30:26 +0900
commit7b4b5e08409f1df2a99c00d40f4859b584cd1dd6 (patch)
tree60cb2a072ea76162e33b5a6312c4108f03df9a7d
parent0a218a97ad31f06eb7f59ccdd428fd46c4b93982 (diff)
Fixed the radix for control chars
-rw-r--r--ext/objspace/objspace_dump.c2
-rw-r--r--test/objspace/test_objspace.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c
index 2659404556..81e490f06d 100644
--- a/ext/objspace/objspace_dump.c
+++ b/ext/objspace/objspace_dump.c
@@ -87,7 +87,7 @@ dump_append_string_value(struct dump_config *dc, VALUE obj)
break;
default:
if (c <= 0x1f)
- dump_append(dc, "\\u%04d", c);
+ dump_append(dc, "\\u%04x", c);
else
dump_append(dc, "%c", c);
}
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index a2242639c7..9d05a4c0f3 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -275,6 +275,10 @@ class TestObjSpace < Test::Unit::TestCase
JSON.parse(info) if defined?(JSON)
end
+ def test_dump_control_char
+ assert_include(ObjectSpace.dump("\x0f"), '"value":"\u000f"')
+ end
+
def test_dump_special_consts
# [ruby-core:69692] [Bug #11291]
assert_equal('null', ObjectSpace.dump(nil))