diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-13 02:48:34 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-13 02:48:34 +0000 |
commit | 2854a7f121861b7508809815532d6827b8bb9929 (patch) | |
tree | e3a43165067b727ac766bf097860e3a4e1976468 /object.c | |
parent | fdfb8804c0d2665e8b82f211fe327b887f2d0b01 (diff) | |
download | ruby-2854a7f121861b7508809815532d6827b8bb9929.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.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -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; } |