summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-12 06:18:11 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-12 06:18:11 +0000
commit0a8f047a983deaf853e8ddc9f70da78f3a83f9ef (patch)
treea81c3aa0c837d42524c6b193cdc717322f1aa591 /io.c
parente960fffda106cc1689b10fca54f99e7a8555bb6f (diff)
* io.c (rb_io_putc): support multibyte characters.
[ruby-core:30697] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/io.c b/io.c
index 7255fc46f4..7625796b2b 100644
--- a/io.c
+++ b/io.c
@@ -6053,9 +6053,15 @@ rb_f_print(int argc, VALUE *argv)
static VALUE
rb_io_putc(VALUE io, VALUE ch)
{
- char c = NUM2CHR(ch);
-
- rb_io_write(io, rb_str_new(&c, 1));
+ VALUE str;
+ if (TYPE(ch) == T_STRING) {
+ str = rb_str_substr(ch, 0, 1);
+ }
+ else {
+ char c = NUM2CHR(ch);
+ str = rb_str_new(&c, 1);
+ }
+ rb_io_write(io, str);
return ch;
}