diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-10 18:57:08 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-10 18:57:08 +0000 |
commit | e3ab670a715769d0d56530675127438bd137089b (patch) | |
tree | fc03650f2be31179d95edfdcdced79a1f02feaf5 /object.c | |
parent | 9e0d92a4e458417e9acf594a00197c291b6393a4 (diff) | |
download | ruby-e3ab670a715769d0d56530675127438bd137089b.tar.gz |
* object.c (rb_inspect): dump inspected result with rb_str_escape()
instead of raising Encoding::CompatibilityError. [Feature #11801]
* string.c (rb_str_escape): added to dump given string like
rb_str_inspect without quotes and always dump in US-ASCII
like rb_str_dump.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -465,6 +465,7 @@ rb_any_to_s(VALUE obj) return str; } +VALUE rb_str_escape(VALUE str); /* * If the default external encoding is ASCII compatible, the encoding of * the inspected result must be compatible with it. @@ -478,11 +479,11 @@ rb_inspect(VALUE obj) rb_encoding *ext = rb_default_external_encoding(); if (!rb_enc_asciicompat(ext)) { if (!rb_enc_str_asciionly_p(str)) - rb_raise(rb_eEncCompatError, "inspected result must be ASCII only if default external encoding is ASCII incompatible"); + return rb_str_escape(str); return str; } if (rb_enc_get(str) != ext && !rb_enc_str_asciionly_p(str)) - rb_raise(rb_eEncCompatError, "inspected result must be ASCII only or use the default external encoding"); + return rb_str_escape(str); return str; } |