diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-21 07:02:55 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-21 07:02:55 +0000 |
commit | e48ea0a5f330ce694e5d6e28a3b4825be13910df (patch) | |
tree | 623f37d5acf019af9868527458fb0de57e639f66 /encoding.c | |
parent | 12df6cf7cece79a1d5d99037b35b6a28c3c3296c (diff) | |
download | ruby-e48ea0a5f330ce694e5d6e28a3b4825be13910df.tar.gz |
* io.c (rb_io_s_read): allow specifying encoding explicitly.
* io.c (rb_io_binmode): specifies encoding to ASCII-8BIT (binary).
* io.c (rb_io_s_read): IO should be in binary mode when offset is
specified.
* encoding.c (rb_to_encoding): returns default encoding if no
corresponding encoding found.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/encoding.c b/encoding.c index 47646cc36c..db384f57b0 100644 --- a/encoding.c +++ b/encoding.c @@ -94,9 +94,12 @@ rb_to_encoding(VALUE enc) { int idx; - if (NIL_P(enc)) return rb_enc_from_index(0); + if (NIL_P(enc)) return 0; idx = enc_check_encoding(enc); if (idx >= 0) return RDATA(enc)->data; + if (NIL_P(enc = rb_check_string_type(enc))) { + return 0; + } if ((idx = rb_enc_find_index(StringValueCStr(enc))) < 0) { rb_raise(rb_eArgError, "unknown encoding name - %s", RSTRING_PTR(enc)); } |