mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Thu Feb 21 17:15:15 2008 Martin Duerst <duerst@it.aoyama.ac.jp>
* transcode.c: Added basic support for passing options to String#encode via a hash. Currently only one option, with one value, is supported: invalid: :ignore (dropping invalid byte sequences instead of producing an error). Option naming is not yet stable! * test/ruby/test_transcode.rb: Added a single test for invalid: :ignore option. Not more tests because most data does not yet distinguish between INVALID and UNKNOWN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ca22f3e168
commit
6d5ef97a32
3 changed files with 45 additions and 6 deletions
|
@ -19,8 +19,6 @@ class TestTranscode < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_errors
|
||||
# we don't have semantics for conversion without attribute yet
|
||||
# maybe 'convert to UTF-8' would be nice :-)
|
||||
assert_raise(ArgumentError) { 'abc'.encode }
|
||||
assert_raise(ArgumentError) { 'abc'.encode! }
|
||||
assert_raise(ArgumentError) { 'abc'.encode('foo', 'bar') }
|
||||
|
@ -241,4 +239,9 @@ class TestTranscode < Test::Unit::TestCase
|
|||
check_utf_32_both_ways("\u{8FF00}", "\x00\x08\xFF\x00")
|
||||
check_utf_32_both_ways("\u{F00FF}", "\x00\x0F\x00\xFF")
|
||||
end
|
||||
|
||||
def test_invalid_ignore
|
||||
# arguments only
|
||||
'abc'.encode('utf-8', invalid: :ignore)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue