diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-05 08:47:01 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-05 08:47:01 +0000 |
commit | fd898245cba1cb65c3bb883ee05f591f2b335242 (patch) | |
tree | 428b83f131ac75259ec4d6ed3701595508b98bc7 | |
parent | 5a7c5d34fbea7263c83f8136e409b559ca4007aa (diff) | |
download | ruby-fd898245cba1cb65c3bb883ee05f591f2b335242.tar.gz |
* ext/stringio/stringio.c (strio_set_encoding): defined for
StringIO#set_encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/stringio/stringio.c | 18 |
2 files changed, 23 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Sun Oct 5 17:39:21 2008 NARUSE, Yui <naruse@ruby-lang.org> + + * ext/stringio/stringio.c (strio_set_encoding): defined for + StringIO#set_encoding. + Sun Oct 5 11:24:42 2008 NARUSE, Yui <naruse@ruby-lang.org> * eval.c: come back definition of environ. diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index c9d1f009b1..c223b8d95c 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1245,6 +1245,23 @@ strio_internal_encoding(VALUE self) } /* + * call-seq: + * strio.set_encoding(ext_enc) => strio + * + * Tagged with the encoding specified. + */ + +static VALUE +strio_set_encoding(VALUE self, VALUE ext_enc) +{ + rb_encoding* enc; + VALUE str = StringIO(self)->string; + enc = rb_to_encoding(ext_enc); + rb_enc_associate(str, enc); + return self; +} + +/* * Pseudo I/O on String object. */ void @@ -1322,4 +1339,5 @@ Init_stringio() rb_define_method(StringIO, "external_encoding", strio_external_encoding, 0); rb_define_method(StringIO, "internal_encoding", strio_internal_encoding, 0); + rb_define_method(StringIO, "set_encoding", strio_set_encoding, 1); } |