mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* transcode.c (econv_primitive_convert): make two arguments,
destination_byteoffset and destination_bytesize, optional. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f3c43ae0c2
commit
9d2accff2b
3 changed files with 21 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Aug 31 14:17:34 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* transcode.c (econv_primitive_convert): make two arguments,
|
||||
destination_byteoffset and destination_bytesize, optional.
|
||||
|
||||
Sun Aug 31 14:12:06 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* transcode.c (make_econv_exception): error message simplified.
|
||||
|
|
|
@ -93,7 +93,16 @@ class TestEncodingConverter < Test::Unit::TestCase
|
|||
assert_equal("\xEF\xBD\xA1".force_encoding("UTF-8") * n, dst)
|
||||
end
|
||||
|
||||
def test_nil_destination_bytesize_with_nonnli_byteoffset
|
||||
def test_nil_destination_bytesize2
|
||||
ec = Encoding::Converter.new("Shift_JIS", "UTF-8")
|
||||
n = 10000
|
||||
src = "\xa1".force_encoding("Shift_JIS") * n
|
||||
ret = ec.primitive_convert(src, dst="")
|
||||
assert_equal(:finished, ret)
|
||||
assert_equal("\xEF\xBD\xA1".force_encoding("UTF-8") * n, dst)
|
||||
end
|
||||
|
||||
def test_nil_destination_bytesize_with_nonnil_byteoffset
|
||||
ec = Encoding::Converter.new("Shift_JIS", "UTF-8")
|
||||
n = 2000
|
||||
src = "\xa1".force_encoding("Shift_JIS") * n
|
||||
|
|
|
@ -2321,6 +2321,8 @@ econv_result_to_symbol(rb_econv_result_t res)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* primitive_convert(source_buffer, destination_buffer) -> symbol
|
||||
* primitive_convert(source_buffer, destination_buffer, destination_byteoffset) -> symbol
|
||||
* primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize) -> symbol
|
||||
* primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, flags) -> symbol
|
||||
*
|
||||
|
@ -2345,9 +2347,12 @@ econv_result_to_symbol(rb_econv_result_t res)
|
|||
* destination_buffer should be a string.
|
||||
*
|
||||
* destination_byteoffset should be an integer or nil.
|
||||
* nil means the end of destination_buffer.
|
||||
* If it is omitted, nil is assumed.
|
||||
*
|
||||
* destination_bytesize and flags should be an integer or nil.
|
||||
* nil means that unlimited.
|
||||
* If it is omitted, nil is assumed.
|
||||
*
|
||||
* primitive_convert convert the content of source_buffer from beginning
|
||||
* and store the result into destination_buffer.
|
||||
|
@ -2409,7 +2414,7 @@ econv_primitive_convert(int argc, VALUE *argv, VALUE self)
|
|||
unsigned long output_byteend;
|
||||
int flags;
|
||||
|
||||
rb_scan_args(argc, argv, "41", &input, &output, &output_byteoffset_v, &output_bytesize_v, &flags_v);
|
||||
rb_scan_args(argc, argv, "23", &input, &output, &output_byteoffset_v, &output_bytesize_v, &flags_v);
|
||||
|
||||
if (NIL_P(output_byteoffset_v))
|
||||
output_byteoffset = 0; /* dummy */
|
||||
|
|
Loading…
Add table
Reference in a new issue