Skip to content

Commit

Permalink
* ext/stringio/stringio.c (strio_external_encoding): defined.
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nurse committed Oct 4, 2008
1 parent 5f898e4 commit 0b18a77
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
31 changes: 31 additions & 0 deletions ext/stringio/stringio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
}

0 comments on commit 0b18a77

Please sign in to comment.