diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-14 16:06:33 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-14 16:06:33 +0000 |
commit | 8eda80ff2cde551e22e9a9803e932184aafdbf38 (patch) | |
tree | 47cc804c9faf9827adaa3ed799fd2eacfd5c31f0 | |
parent | c9453ecc049269a637d5d39daa927fc9b4a462b0 (diff) | |
download | ruby-8eda80ff2cde551e22e9a9803e932184aafdbf38.tar.gz |
* transcode.c (econv_primitive_convert): set destination_buffer
encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_econv.rb | 8 | ||||
-rw-r--r-- | transcode.c | 4 |
3 files changed, 17 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Fri Aug 15 01:05:39 2008 Tanaka Akira <akr@fsij.org> + + * transcode.c (econv_primitive_convert): set destination_buffer + encoding. + Fri Aug 15 00:52:40 2008 Tanaka Akira <akr@fsij.org> * include/ruby/encoding.h (rb_econv_output): declared. diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index 98ed310504..af846ad45b 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -31,6 +31,14 @@ class TestEncodingConverter < Test::Unit::TestCase assert_equal(Encoding::EUC_JP, ec.destination_encoding) end + def test_result_encoding + ec = Encoding::Converter.new("UTF-8", "EUC-JP") + dst = "".force_encoding("ASCII-8BIT") + assert_equal(Encoding::ASCII_8BIT, dst.encoding) + ec.primitive_convert("\u{3042}", dst, nil, 10) + assert_equal(Encoding::EUC_JP, dst.encoding) + end + def test_output_region ec = Encoding::Converter.new("UTF-8", "EUC-JP") ec.primitive_convert(src="a", dst="b", nil, 1, Encoding::Converter::PARTIAL_INPUT) diff --git a/transcode.c b/transcode.c index b8c8d1a1ae..2e189b935b 100644 --- a/transcode.c +++ b/transcode.c @@ -1676,6 +1676,10 @@ econv_primitive_convert(int argc, VALUE *argv, VALUE self) rb_str_set_len(output, op-(unsigned char *)RSTRING_PTR(output)); rb_str_drop_bytes(input, ip - (unsigned char *)RSTRING_PTR(input)); + if (ec->destination_encoding) { + rb_enc_associate(output, ec->destination_encoding); + } + switch (res) { case econv_invalid_byte_sequence: return ID2SYM(rb_intern("invalid_byte_sequence")); case econv_undefined_conversion: return ID2SYM(rb_intern("undefined_conversion")); |