1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* transcode.c (output_replacement_character):

rename from _get_replacement_character.

* transcode.c (output_replacement_character):
  fix replacement on UTF-32{BE,LE}. [ruby-dev:35705]

* transcode.c (transcode_loop): ditto.

* test/ruby/test_transcode.rb (test_invalid_replace):
  add for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2008-07-31 20:35:35 +00:00
parent f3730b8260
commit 00aef398d0
3 changed files with 53 additions and 18 deletions

View file

@ -254,6 +254,21 @@ class TestTranscode < Test::Unit::TestCase
"\x82\xAB".encode('UTF-16BE', 'UTF-8', invalid: :ignore))
end
def test_invalid_replace
# arguments only
assert_nothing_raised { 'abc'.encode('UTF-8', invalid: :replace) }
assert_equal("\xEF\xBF\xBD".force_encoding("UTF-8"),
"\x80".encode("UTF-8", "UTF-16BE", invalid: :replace))
assert_equal("\xFF\xFD".force_encoding("UTF-16BE"),
"\x80".encode("UTF-16BE", "UTF-8", invalid: :replace))
assert_equal("\xFD\xFF".force_encoding("UTF-16LE"),
"\x80".encode("UTF-16LE", "UTF-8", invalid: :replace))
assert_equal("\x00\x00\xFF\xFD".force_encoding("UTF-32BE"),
"\x80".encode("UTF-32BE", "UTF-8", invalid: :replace))
assert_equal("\xFD\xFF\x00\x00".force_encoding("UTF-32LE"),
"\x80".encode("UTF-32LE", "UTF-8", invalid: :replace))
end
def test_shift_jis
check_both_ways("\u3000", "\x81\x40", 'shift_jis') # full-width space
check_both_ways("\u00D7", "\x81\x7E", 'shift_jis') # ~