mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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:
parent
c9453ecc04
commit
8eda80ff2c
3 changed files with 17 additions and 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.
|
||||
|
|
|
@ -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"));
|
||||
|
|
Loading…
Reference in a new issue