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_set_encoding):

StringIO#set_encoding can get 2nd argument and optional hash
  for API compatibility to IO. [ruby-dev:42356]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2010-10-10 21:54:22 +00:00
parent 6221ba109c
commit 47cb5a93e5
3 changed files with 30 additions and 7 deletions

View file

@ -1,3 +1,9 @@
Mon Oct 11 06:38:27 2010 NARUSE, Yui <naruse@ruby-lang.org>
* ext/stringio/stringio.c (strio_set_encoding):
StringIO#set_encoding can get 2nd argument and optional hash
for API compatibility to IO. [ruby-dev:42356]
Mon Oct 11 06:11:30 2010 NARUSE, Yui <naruse@ruby-lang.org>
* io.c (rb_io_set_encoding): use rb_funcall2 when the io is not
@ -130,9 +136,10 @@ Mon Oct 4 00:01:53 2010 wanabe <s.wanabe@gmail.com>
* win32/mkexports.rb: no longer use 'mingw64'. a patch from Luis Lavena
at [ruby-core:32678].
Sun Oct 3 20:36:37 2010 Akio Tajima (arton) <artonx@yahoo.co.jp>
Sun Oct 3 20:36:37 2010 Akio Tajima (arton) <artonx@yahoo.co.jp>
* test/win32ole/test_folderitem2_invokeverb.rb: Change creating shortcut verb to 'Link' [Bug #3339]
* test/win32ole/test_folderitem2_invokeverb.rb: Change creating
shortcut verb to 'Link' [Bug #3339]
Sun Oct 3 19:44:23 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>

4
NEWS
View file

@ -60,6 +60,10 @@ with all sufficient information, see the ChangeLog file.
* URI::Generic#hostname
* URI::Generic#hostname=
* stringio
* extended methods:
* StringIO#set_encoding can get 2nd argument and optional hash.
=== Compatibility issues (excluding feature bug fixes)
* Kernel#respond_to?

View file

@ -1365,17 +1365,29 @@ strio_internal_encoding(VALUE self)
/*
* call-seq:
* strio.set_encoding(ext_enc) => strio
* strio.set_encoding(ext_enc, [int_enc[, opt]]) => strio
*
* Tagged with the encoding specified.
* Specify the encoding of the StringIO as <i>ext_enc</i>.
* Use the default external encoding if <i>ext_enc</i> is nil.
* 2nd argument <i>int_enc</i> and optional hash <i>opt</i> argument
* are ignored; they are for API compatibility to IO.
*/
static VALUE
strio_set_encoding(VALUE self, VALUE ext_enc)
strio_set_encoding(int argc, VALUE *argv, VALUE self)
{
rb_encoding* enc;
VALUE str = StringIO(self)->string;
enc = rb_to_encoding(ext_enc);
VALUE ext_enc, int_enc, opt;
argc = rb_scan_args(argc, argv, "11:", &ext_enc, &int_enc, &opt);
if (NIL_P(ext_enc)) {
enc = rb_default_external_encoding();
}
else {
enc = rb_to_encoding(ext_enc);
}
rb_enc_associate(str, enc);
return self;
}
@ -1462,5 +1474,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);
rb_define_method(StringIO, "set_encoding", strio_set_encoding, -1);
}