summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-31 06:04:27 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-31 06:04:27 +0000
commitd16fc7ca69d497159cd7456ae76642a651396dad (patch)
tree3261704918d0decd66c1af0c3cc541dc1a1d7d48 /string.c
parentd13e191d2593093f3c34a2cb6778d8676ca54d6f (diff)
* string.c (rb_str_inspect): inspect as ASCII when the codepoint
of a character in Unicode string is ASCII printable one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/string.c b/string.c
index ae4289380f..48ebf89815 100644
--- a/string.c
+++ b/string.c
@@ -4166,7 +4166,10 @@ rb_str_inspect(VALUE str)
else {
if (p - n > prev) str_buf_cat(result, prev, p - n - prev);
if (unicode_p) {
- if (c < 0x10000) {
+ if (c < 0x100 && ISPRINT(c)) {
+ snprintf(buf, CHAR_ESC_LEN, "%c", c);
+ }
+ else if (c < 0x10000) {
snprintf(buf, CHAR_ESC_LEN, "\\u%04X", c);
}
else {