mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
String#inspect to use hexadecimal, not octal to print unprintable.
This commit is contained in:
+7
-7
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -685,7 +685,7 @@ assert('String#inspect', '15.2.10.5.46') do
|
||||
("\1" * 100).inspect
|
||||
end
|
||||
|
||||
assert_equal "\"\\000\"", "\0".inspect
|
||||
assert_equal "\"\\x00\"", "\0".inspect
|
||||
end
|
||||
|
||||
# Not ISO specified
|
||||
|
||||
Reference in New Issue
Block a user