From 1d5526042394630a1c69b0d2169fa02cce36c20a Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 12 Feb 2018 10:29:24 +0900 Subject: `String#inspect` to use hexadecimal, not octal to print unprintable. --- src/string.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/string.c b/src/string.c index c2284d552..e8c60a660 100644 --- a/src/string.c +++ b/src/string.c @@ -2542,10 +2542,10 @@ mrb_str_dump(mrb_state *mrb, mrb_value str) } else { *q++ = '\\'; - q[2] = '0' + c % 8; c /= 8; - q[1] = '0' + c % 8; c /= 8; - q[0] = '0' + c % 8; - q += 3; + *q++ = 'x'; + q[1] = mrb_digitmap[c % 16]; c /= 16; + q[0] = mrb_digitmap[c % 16]; + q += 2; } } } @@ -2685,9 +2685,9 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str) } else { buf[0] = '\\'; - buf[3] = '0' + c % 8; c /= 8; - buf[2] = '0' + c % 8; c /= 8; - buf[1] = '0' + c % 8; + buf[1] = 'x'; + buf[3] = mrb_digitmap[c % 16]; c /= 16; + buf[2] = mrb_digitmap[c % 16]; mrb_str_cat(mrb, result, buf, 4); continue; } -- cgit v1.2.3