* 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
This commit is contained in:
akr 2008-08-14 16:06:33 +00:00
Родитель c9453ecc04
Коммит 8eda80ff2c
3 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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)

Просмотреть файл

@ -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"));