aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 02:48:34 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 02:48:34 +0000
commitc69ef4127734c583770b13411e49cbec7af817cd (patch)
treee3a43165067b727ac766bf097860e3a4e1976468 /object.c
parent9d3642f25adf8e143c0717d81017ca9f249aa995 (diff)
downloadruby-c69ef4127734c583770b13411e49cbec7af817cd.tar.gz
* object.c (rb_inspect): check the default internal encoding as
String#inspect do. [ruby-dev:49415] [Bug #11787] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/object.c b/object.c
index 3111701c58..99f58a8f6c 100644
--- a/object.c
+++ b/object.c
@@ -467,22 +467,23 @@ rb_any_to_s(VALUE obj)
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.
- * If the default external encoding is ASCII incompatible,
+ * If the default internal or external encoding is ASCII compatible,
+ * the encoding of the inspected result must be compatible with it.
+ * If the default internal or external encoding is ASCII incompatible,
* the result must be ASCII only.
*/
VALUE
rb_inspect(VALUE obj)
{
VALUE str = rb_obj_as_string(rb_funcallv(obj, id_inspect, 0, 0));
- rb_encoding *ext = rb_default_external_encoding();
- if (!rb_enc_asciicompat(ext)) {
+ rb_encoding *enc = rb_default_internal_encoding();
+ if (enc == NULL) enc = rb_default_external_encoding();
+ if (!rb_enc_asciicompat(enc)) {
if (!rb_enc_str_asciionly_p(str))
return rb_str_escape(str);
return str;
}
- if (rb_enc_get(str) != ext && !rb_enc_str_asciionly_p(str))
+ if (rb_enc_get(str) != enc && !rb_enc_str_asciionly_p(str))
return rb_str_escape(str);
return str;
}