1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/stringio/stringio.c (strio_external_encoding): defined.

* ext/stringio/stringio.c (strio_internal_encoding): defined.

* ext/stringio/stringio.c (Init_stringio): define above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2008-10-04 09:56:20 +00:00
parent 5f898e44a7
commit 0b18a77e7d
2 changed files with 39 additions and 0 deletions

View file

@ -1,3 +1,11 @@
Sat Oct 4 18:47:22 2008 NARUSE, Yui <naruse@ruby-lang.org>
* ext/stringio/stringio.c (strio_external_encoding): defined.
* ext/stringio/stringio.c (strio_internal_encoding): defined.
* ext/stringio/stringio.c (Init_stringio): define above.
Sat Oct 4 15:52:17 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* test/mini/test_mini_test.rb: recovered.

View file

@ -1216,6 +1216,34 @@ strio_truncate(VALUE self, VALUE len)
return len;
}
/*
* call-seq:
* strio.external_encoding => encoding
*
* Returns the Encoding object that represents the encoding of the file.
* If strio is write mode and no encoding is specified, returns <code>nil</code>.
*/
static VALUE
strio_external_encoding(VALUE self)
{
return rb_enc_from_encoding(rb_enc_get(StringIO(self)->string));
}
/*
* call-seq:
* strio.internal_encoding => encoding
*
* Returns the Encoding of the internal string if conversion is
* specified. Otherwise returns nil.
*/
static VALUE
strio_internal_encoding(VALUE self)
{
return Qnil;
}
/*
* Pseudo I/O on String object.
*/
@ -1291,4 +1319,7 @@ Init_stringio()
rb_define_method(StringIO, "size", strio_size, 0);
rb_define_method(StringIO, "length", strio_size, 0);
rb_define_method(StringIO, "truncate", strio_truncate, 1);
rb_define_method(StringIO, "external_encoding", strio_external_encoding, 0);
rb_define_method(StringIO, "internal_encoding", strio_internal_encoding, 0);
}