/test/ruby/test_transcode.rb
http://github.com/ruby/ruby · Ruby · 2268 lines · 2145 code · 89 blank · 34 comment · 0 complexity · c15189a37de3cb325d5f3b99c587bec2 MD5 · raw file
Large files are truncated click here to view the full file
- # encoding: ASCII-8BIT # make sure this runs in binary mode
- # frozen_string_literal: false
- # some of the comments are in UTF-8
- require 'test/unit'
- class TestTranscode < Test::Unit::TestCase
- def test_errors
- assert_raise(Encoding::ConverterNotFoundError) { 'abc'.encode('foo', 'bar') }
- assert_raise(Encoding::ConverterNotFoundError) { 'abc'.encode!('foo', 'bar') }
- assert_raise(Encoding::ConverterNotFoundError) { 'abc'.force_encoding('utf-8').encode('foo') }
- assert_raise(Encoding::ConverterNotFoundError) { 'abc'.force_encoding('utf-8').encode!('foo') }
- assert_raise(Encoding::UndefinedConversionError) { "\x80".encode('utf-8','ASCII-8BIT') }
- assert_raise(Encoding::InvalidByteSequenceError) { "\x80".encode('utf-8','US-ASCII') }
- assert_raise(Encoding::UndefinedConversionError) { "\xA5".encode('utf-8','iso-8859-3') }
- assert_raise(FrozenError) { 'hello'.freeze.encode!('iso-8859-1') }
- assert_raise(FrozenError) { '\u3053\u3093\u306b\u3061\u306f'.freeze.encode!('iso-8859-1') } # こんにちは
- end
- def test_arguments
- assert_equal('abc', 'abc'.force_encoding('utf-8').encode('iso-8859-1'))
- # check that encoding is kept when no conversion is done
- assert_equal('abc'.force_encoding('Shift_JIS'), 'abc'.force_encoding('Shift_JIS').encode('Shift_JIS'))
- assert_equal('abc'.force_encoding('Shift_JIS'), 'abc'.force_encoding('Shift_JIS').encode!('Shift_JIS'))
- # assert that encoding is correctly set
- assert_equal("D\u00FCrst".encoding, "D\xFCrst".force_encoding('iso-8859-1').encode('utf-8').encoding)
- # check that Encoding can be used as parameter
- assert_equal("D\u00FCrst", "D\xFCrst".encode('utf-8', Encoding.find('ISO-8859-1')))
- assert_equal("D\u00FCrst", "D\xFCrst".encode(Encoding.find('utf-8'), 'ISO-8859-1'))
- assert_equal("D\u00FCrst", "D\xFCrst".encode(Encoding.find('utf-8'), Encoding.find('ISO-8859-1')))
- end
- def test_noargument
- EnvUtil.with_default_internal(nil) do
- assert_equal("\u3042".encode, "\u3042")
- assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode,
- "\xE3\x81\x82\x81".force_encoding("utf-8"))
- end
- EnvUtil.with_default_internal('EUC-JP') do
- assert_equal("\u3042".encode, "\xA4\xA2".force_encoding('EUC-JP'))
- assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode,
- "\xA4\xA2?".force_encoding('EUC-JP'))
- end
- end
- def test_length
- assert_equal("\u20AC"*20, ("\xA4"*20).encode('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*20, ("\xA4"*20).encode!('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*2000, ("\xA4"*2000).encode('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*2000, ("\xA4"*2000).encode!('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*200000, ("\xA4"*200000).encode('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*200000, ("\xA4"*200000).encode!('utf-8', 'iso-8859-15'))
- end
- def check_both_ways(utf8, raw, encoding)
- assert_equal(utf8.force_encoding('utf-8'), raw.encode('utf-8', encoding),utf8.dump+raw.dump)
- assert_equal(raw.force_encoding(encoding), utf8.encode(encoding, 'utf-8'))
- end
- def check_both_ways2(str1, enc1, str2, enc2)
- assert_equal(str1.force_encoding(enc1), str2.encode(enc1, enc2))
- assert_equal(str2.force_encoding(enc2), str1.encode(enc2, enc1))
- end
- def test_encoding_of_ascii_originating_from_binary
- binary_string = [0x82, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
- 0x61, 0x20, 0x76, 0x65, 0x72, 0x79, 0x20, 0x6c, 0x6f,
- 0x6e, 0x67, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67]
- class << binary_string
- # create a copy on write substring that contains
- # just the ascii characters (i.e. this is...), in JRuby
- # the underlying string have the same buffer backing
- # it up, but the offset of the string will be 1 instead
- # of 0.
- def make_cow_substring
- pack('C27').slice(1, 26)
- end
- end
- ascii_string = binary_string.make_cow_substring
- assert_equal("this is a very long string", ascii_string)
- assert_equal(Encoding::ASCII_8BIT, ascii_string.encoding)
- utf8_string = nil
- assert_nothing_raised("JRUBY-6764") do
- utf8_string = ascii_string.encode(Encoding::UTF_8)
- end
- assert_equal("this is a very long string", utf8_string)
- assert_equal(Encoding::UTF_8, utf8_string.encoding)
- end
- def test_encodings
- check_both_ways("\u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D",
- "\x82\xdc\x82\xc2\x82\xe0\x82\xc6 \x82\xe4\x82\xab\x82\xd0\x82\xeb", 'shift_jis') # まつもと ゆきひろ
- check_both_ways("\u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D",
- "\xa4\xde\xa4\xc4\xa4\xe2\xa4\xc8 \xa4\xe6\xa4\xad\xa4\xd2\xa4\xed", 'euc-jp')
- check_both_ways("\u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D",
- "\xa4\xde\xa4\xc4\xa4\xe2\xa4\xc8 \xa4\xe6\xa4\xad\xa4\xd2\xa4\xed", 'euc-jis-2004')
- check_both_ways("\u677E\u672C\u884C\u5F18", "\x8f\xbc\x96\x7b\x8d\x73\x8d\x4f", 'shift_jis') # 松本行弘
- check_both_ways("\u677E\u672C\u884C\u5F18", "\xbe\xbe\xcb\xdc\xb9\xd4\xb9\xb0", 'euc-jp')
- check_both_ways("\u677E\u672C\u884C\u5F18", "\xbe\xbe\xcb\xdc\xb9\xd4\xb9\xb0", 'euc-jis-2004')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-1') # Dürst
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-2')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-3')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-4')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-9')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-10')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-13')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-14')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-15')
- check_both_ways("r\u00E9sum\u00E9", "r\xE9sum\xE9", 'iso-8859-1') # résumé
- check_both_ways("\u0065\u006C\u0151\u00ED\u0072\u00E1\u0073", "el\xF5\xEDr\xE1s", 'iso-8859-2') # előírás
- check_both_ways("\u043F\u0435\u0440\u0435\u0432\u043E\u0434",
- "\xDF\xD5\xE0\xD5\xD2\xDE\xD4", 'iso-8859-5') # перевод
- check_both_ways("\u0643\u062A\u0628", "\xE3\xCA\xC8", 'iso-8859-6') # كتب
- check_both_ways("\u65E5\u8A18", "\x93\xFA\x8BL", 'shift_jis') # 日記
- check_both_ways("\u65E5\u8A18", "\xC6\xFC\xB5\xAD", 'euc-jp')
- check_both_ways("\u65E5\u8A18", "\xC6\xFC\xB5\xAD", 'euc-jis-2004')
- check_both_ways("\uC560\uC778\uAD6C\uD568\u0020\u6734\uC9C0\uC778",
- "\xBE\xD6\xC0\xCE\xB1\xB8\xC7\xD4\x20\xDA\xD3\xC1\xF6\xC0\xCE", 'euc-kr') # 애인구함 朴지인
- check_both_ways("\uC544\uD58F\uD58F\u0020\uB620\uBC29\uD6BD\uB2D8\u0020\uC0AC\uB791\uD716",
- "\xBE\xC6\xC1\x64\xC1\x64\x20\x8C\x63\xB9\xE6\xC4\x4F\xB4\xD4\x20\xBB\xE7\xB6\xFB\xC5\x42", 'cp949') # 아햏햏 똠방횽님 사랑휖
- assert_equal(Encoding::ISO_8859_1, "D\xFCrst".force_encoding('iso-8859-2').encode('iso-8859-1', 'iso-8859-1').encoding)
- end
- def test_twostep
- assert_equal("D\xFCrst".force_encoding('iso-8859-2'), "D\xFCrst".encode('iso-8859-2', 'iso-8859-1'))
- end
- def test_ascii_range
- encodings = [
- 'US-ASCII', 'ASCII-8BIT',
- 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3',
- 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6',
- 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
- 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-13',
- 'ISO-8859-14', 'ISO-8859-15',
- 'EUC-JP', 'SHIFT_JIS', 'EUC-KR'
- ]
- all_ascii = (0..127).to_a.pack 'C*'
- encodings.each do |enc|
- test_start = all_ascii
- assert_equal(test_start, test_start.encode('UTF-8',enc).encode(enc).force_encoding('ASCII-8BIT'))
- end
- end
- def test_all_bytes
- encodings_8859 = [
- 'ISO-8859-1', 'ISO-8859-2',
- #'ISO-8859-3', # not all bytes used
- 'ISO-8859-4', 'ISO-8859-5',
- #'ISO-8859-6', # not all bytes used
- #'ISO-8859-7', # not all bytes used
- #'ISO-8859-8', # not all bytes used
- 'ISO-8859-9', 'ISO-8859-10',
- #'ISO-8859-11', # not all bytes used
- #'ISO-8859-12', # not available
- 'ISO-8859-13','ISO-8859-14','ISO-8859-15',
- #'ISO-8859-16', # not available
- ]
- all_bytes = (0..255).to_a.pack 'C*'
- encodings_8859.each do |enc|
- test_start = all_bytes
- assert_equal(test_start, test_start.encode('UTF-8',enc).encode(enc).force_encoding('ASCII-8BIT'))
- end
- end
- def test_windows_874
- check_both_ways("\u20AC", "\x80", 'windows-874') # €
- assert_raise(Encoding::UndefinedConversionError) { "\x81".encode("utf-8", 'windows-874') }
- assert_raise(Encoding::UndefinedConversionError) { "\x84".encode("utf-8", 'windows-874') }
- check_both_ways("\u2026", "\x85", 'windows-874') # …
- assert_raise(Encoding::UndefinedConversionError) { "\x86".encode("utf-8", 'windows-874') }
- assert_raise(Encoding::UndefinedConversionError) { "\x8F".encode("utf-8", 'windows-874') }
- assert_raise(Encoding::UndefinedConversionError) { "\x90".encode("utf-8", 'windows-874') }
- check_both_ways("\u2018", "\x91", 'windows-874') # ‘
- check_both_ways("\u2014", "\x97", 'windows-874') # —
- assert_raise(Encoding::UndefinedConversionError) { "\x98".encode("utf-8", 'windows-874') }
- assert_raise(Encoding::UndefinedConversionError) { "\x9F".encode("utf-8", 'windows-874') }
- check_both_ways("\u00A0", "\xA0", 'windows-874') # non-breaking space
- check_both_ways("\u0E0F", "\xAF", 'windows-874') # ฏ
- check_both_ways("\u0E10", "\xB0", 'windows-874') # ฐ
- check_both_ways("\u0E1F", "\xBF", 'windows-874') # ฟ
- check_both_ways("\u0E20", "\xC0", 'windows-874') # ภ
- check_both_ways("\u0E2F", "\xCF", 'windows-874') # ฯ
- check_both_ways("\u0E30", "\xD0", 'windows-874') # ะ
- check_both_ways("\u0E3A", "\xDA", 'windows-874') # ฺ
- assert_raise(Encoding::UndefinedConversionError) { "\xDB".encode("utf-8", 'windows-874') }
- assert_raise(Encoding::UndefinedConversionError) { "\xDE".encode("utf-8", 'windows-874') }
- check_both_ways("\u0E3F", "\xDF", 'windows-874') # ฿
- check_both_ways("\u0E40", "\xE0", 'windows-874') # เ
- check_both_ways("\u0E4F", "\xEF", 'windows-874') # ๏
- check_both_ways("\u0E50", "\xF0", 'windows-874') # ๐
- check_both_ways("\u0E5B", "\xFB", 'windows-874') # ๛
- assert_raise(Encoding::UndefinedConversionError) { "\xFC".encode("utf-8", 'windows-874') }
- assert_raise(Encoding::UndefinedConversionError) { "\xFF".encode("utf-8", 'windows-874') }
- end
- def test_windows_1250
- check_both_ways("\u20AC", "\x80", 'windows-1250') # €
- assert_raise(Encoding::UndefinedConversionError) { "\x81".encode("utf-8", 'windows-1250') }
- check_both_ways("\u201A", "\x82", 'windows-1250') # ‚
- assert_raise(Encoding::UndefinedConversionError) { "\x83".encode("utf-8", 'windows-1250') }
- check_both_ways("\u201E", "\x84", 'windows-1250') # „
- check_both_ways("\u2021", "\x87", 'windows-1250') # ‡
- assert_raise(Encoding::UndefinedConversionError) { "\x88".encode("utf-8", 'windows-1250') }
- check_both_ways("\u2030", "\x89", 'windows-1250') # ‰
- check_both_ways("\u0179", "\x8F", 'windows-1250') # Ź
- assert_raise(Encoding::UndefinedConversionError) { "\x90".encode("utf-8", 'windows-1250') }
- check_both_ways("\u2018", "\x91", 'windows-1250') # ‘
- check_both_ways("\u2014", "\x97", 'windows-1250') # —
- assert_raise(Encoding::UndefinedConversionError) { "\x98".encode("utf-8", 'windows-1250') }
- check_both_ways("\u2122", "\x99", 'windows-1250') # ™
- check_both_ways("\u00A0", "\xA0", 'windows-1250') # non-breaking space
- check_both_ways("\u017B", "\xAF", 'windows-1250') # Ż
- check_both_ways("\u00B0", "\xB0", 'windows-1250') # °
- check_both_ways("\u017C", "\xBF", 'windows-1250') # ż
- check_both_ways("\u0154", "\xC0", 'windows-1250') # Ŕ
- check_both_ways("\u010E", "\xCF", 'windows-1250') # Ď
- check_both_ways("\u0110", "\xD0", 'windows-1250') # Đ
- check_both_ways("\u00DF", "\xDF", 'windows-1250') # ß
- check_both_ways("\u0155", "\xE0", 'windows-1250') # ŕ
- check_both_ways("\u010F", "\xEF", 'windows-1250') # ď
- check_both_ways("\u0111", "\xF0", 'windows-1250') # đ
- check_both_ways("\u02D9", "\xFF", 'windows-1250') # ˙
- end
- def test_windows_1251
- check_both_ways("\u0402", "\x80", 'windows-1251') # Ђ
- check_both_ways("\u20AC", "\x88", 'windows-1251') # €
- check_both_ways("\u040F", "\x8F", 'windows-1251') # Џ
- check_both_ways("\u0452", "\x90", 'windows-1251') # ђ
- assert_raise(Encoding::UndefinedConversionError) { "\x98".encode("utf-8", 'windows-1251') }
- check_both_ways("\u045F", "\x9F", 'windows-1251') # џ
- check_both_ways("\u00A0", "\xA0", 'windows-1251') # non-breaking space
- check_both_ways("\u0407", "\xAF", 'windows-1251') # Ї
- check_both_ways("\u00B0", "\xB0", 'windows-1251') # °
- check_both_ways("\u0457", "\xBF", 'windows-1251') # ї
- check_both_ways("\u0410", "\xC0", 'windows-1251') # А
- check_both_ways("\u041F", "\xCF", 'windows-1251') # П
- check_both_ways("\u0420", "\xD0", 'windows-1251') # Р
- check_both_ways("\u042F", "\xDF", 'windows-1251') # Я
- check_both_ways("\u0430", "\xE0", 'windows-1251') # а
- check_both_ways("\u043F", "\xEF", 'windows-1251') # п
- check_both_ways("\u0440", "\xF0", 'windows-1251') # р
- check_both_ways("\u044F", "\xFF", 'windows-1251') # я
- end
- def test_windows_1252
- check_both_ways("\u20AC", "\x80", 'windows-1252') # €
- assert_raise(Encoding::UndefinedConversionError) { "\x81".encode("utf-8", 'windows-1252') }
- check_both_ways("\u201A", "\x82", 'windows-1252') # ‚
- check_both_ways("\u0152", "\x8C", 'windows-1252') # >Œ
- assert_raise(Encoding::UndefinedConversionError) { "\x8D".encode("utf-8", 'windows-1252') }
- check_both_ways("\u017D", "\x8E", 'windows-1252') # Ž
- assert_raise(Encoding::UndefinedConversionError) { "\x8F".encode("utf-8", 'windows-1252') }
- assert_raise(Encoding::UndefinedConversionError) { "\x90".encode("utf-8", 'windows-1252') }
- check_both_ways("\u2018", "\x91", 'windows-1252') #‘
- check_both_ways("\u0153", "\x9C", 'windows-1252') # œ
- assert_raise(Encoding::UndefinedConversionError) { "\x9D".encode("utf-8", 'windows-1252') }
- check_both_ways("\u017E", "\x9E", 'windows-1252') # ž
- check_both_ways("\u00A0", "\xA0", 'windows-1252') # non-breaking space
- check_both_ways("\u00AF", "\xAF", 'windows-1252') # ¯
- check_both_ways("\u00B0", "\xB0", 'windows-1252') # °
- check_both_ways("\u00BF", "\xBF", 'windows-1252') # ¿
- check_both_ways("\u00C0", "\xC0", 'windows-1252') # À
- check_both_ways("\u00CF", "\xCF", 'windows-1252') # Ï
- check_both_ways("\u00D0", "\xD0", 'windows-1252') # Ð
- check_both_ways("\u00DF", "\xDF", 'windows-1252') # ß
- check_both_ways("\u00E0", "\xE0", 'windows-1252') # à
- check_both_ways("\u00EF", "\xEF", 'windows-1252') # ï
- check_both_ways("\u00F0", "\xF0", 'windows-1252') # ð
- check_both_ways("\u00FF", "\xFF", 'windows-1252') # ÿ
- end
- def test_windows_1253
- check_both_ways("\u20AC", "\x80", 'windows-1253') # €
- assert_raise(Encoding::UndefinedConversionError) { "\x81".encode("utf-8", 'windows-1253') }
- check_both_ways("\u201A", "\x82", 'windows-1253') # ‚
- check_both_ways("\u2021", "\x87", 'windows-1253') # ‡
- assert_raise(Encoding::UndefinedConversionError) { "\x88".encode("utf-8", 'windows-1253') }
- check_both_ways("\u2030", "\x89", 'windows-1253') # ‰
- assert_raise(Encoding::UndefinedConversionError) { "\x8A".encode("utf-8", 'windows-1253') }
- check_both_ways("\u2039", "\x8B", 'windows-1253') # ‹
- assert_raise(Encoding::UndefinedConversionError) { "\x8C".encode("utf-8", 'windows-1253') }
- assert_raise(Encoding::UndefinedConversionError) { "\x8F".encode("utf-8", 'windows-1253') }
- assert_raise(Encoding::UndefinedConversionError) { "\x90".encode("utf-8", 'windows-1253') }
- check_both_ways("\u2018", "\x91", 'windows-1253') # ‘
- check_both_ways("\u2014", "\x97", 'windows-1253') # —
- assert_raise(Encoding::UndefinedConversionError) { "\x98".encode("utf-8", 'windows-1253') }
- check_both_ways("\u2122", "\x99", 'windows-1253') # ™
- assert_raise(Encoding::UndefinedConversionError) { "\x9A".encode("utf-8", 'windows-1253') }
- check_both_ways("\u203A", "\x9B", 'windows-1253') # ›
- assert_raise(Encoding::UndefinedConversionError) { "\x9C".encode("utf-8", 'windows-1253') }
- assert_raise(Encoding::UndefinedConversionError) { "\x9F".encode("utf-8", 'windows-1253') }
- check_both_ways("\u00A0", "\xA0", 'windows-1253') # non-breaking space
- check_both_ways("\u2015", "\xAF", 'windows-1253') # ―
- check_both_ways("\u00B0", "\xB0", 'windows-1253') # °
- check_both_ways("\u038F", "\xBF", 'windows-1253') # Ώ
- check_both_ways("\u0390", "\xC0", 'windows-1253') # ΐ
- check_both_ways("\u039F", "\xCF", 'windows-1253') # Ο
- check_both_ways("\u03A0", "\xD0", 'windows-1253') # Π
- check_both_ways("\u03A1", "\xD1", 'windows-1253') # Ρ
- assert_raise(Encoding::UndefinedConversionError) { "\xD2".encode("utf-8", 'windows-1253') }
- check_both_ways("\u03A3", "\xD3", 'windows-1253') # Σ
- check_both_ways("\u03AF", "\xDF", 'windows-1253') # ί
- check_both_ways("\u03B0", "\xE0", 'windows-1253') # ΰ
- check_both_ways("\u03BF", "\xEF", 'windows-1253') # ο
- check_both_ways("\u03C0", "\xF0", 'windows-1253') # π
- check_both_ways("\u03CE", "\xFE", 'windows-1253') # ώ
- assert_raise(Encoding::UndefinedConversionError) { "\xFF".encode("utf-8", 'windows-1253') }
- end
- def test_windows_1254
- check_both_ways("\u20AC", "\x80", 'windows-1254') # €
- assert_raise(Encoding::UndefinedConversionError) { "\x81".encode("utf-8", 'windows-1254') }
- check_both_ways("\u201A", "\x82", 'windows-1254') # ‚
- check_both_ways("\u0152", "\x8C", 'windows-1254') # Œ
- assert_raise(Encoding::UndefinedConversionError) { "\x8D".encode("utf-8", 'windows-1254') }
- assert_raise(Encoding::UndefinedConversionError) { "\x8F".encode("utf-8", 'windows-1254') }
- assert_raise(Encoding::UndefinedConversionError) { "\x90".encode("utf-8", 'windows-1254') }
- check_both_ways("\u2018", "\x91", 'windows-1254') # ‘
- check_both_ways("\u0153", "\x9C", 'windows-1254') # œ
- assert_raise(Encoding::UndefinedConversionError) { "\x9D".encode("utf-8", 'windows-1254') }
- assert_raise(Encoding::UndefinedConversionError) { "\x9E".encode("utf-8", 'windows-1254') }
- check_both_ways("\u0178", "\x9F", 'windows-1254') # Ÿ
- check_both_ways("\u00A0", "\xA0", 'windows-1254') # non-breaking space
- check_both_ways("\u00AF", "\xAF", 'windows-1254') # ¯
- check_both_ways("\u00B0", "\xB0", 'windows-1254') # °
- check_both_ways("\u00BF", "\xBF", 'windows-1254') # ¿
- check_both_ways("\u00C0", "\xC0", 'windows-1254') # À
- check_both_ways("\u00CF", "\xCF", 'windows-1254') # Ï
- check_both_ways("\u011E", "\xD0", 'windows-1254') # Ğ
- check_both_ways("\u00DF", "\xDF", 'windows-1254') # ß
- check_both_ways("\u00E0", "\xE0", 'windows-1254') # à
- check_both_ways("\u00EF", "\xEF", 'windows-1254') # ï
- check_both_ways("\u011F", "\xF0", 'windows-1254') # ğ
- check_both_ways("\u00FF", "\xFF", 'windows-1254') # ÿ
- end
- def test_windows_1255
- check_both_ways("\u20AC", "\x80", 'windows-1255') # €
- assert_raise(Encoding::UndefinedConversionError) { "\x81".encode("utf-8", 'windows-1255') }
- check_both_ways("\u201A", "\x82", 'windows-1255') # ‚
- check_both_ways("\u2030", "\x89", 'windows-1255') # ‰
- assert_raise(Encoding::UndefinedConversionError) { "\x8A".encode("utf-8", 'windows-1255') }
- check_both_ways("\u2039", "\x8B", 'windows-1255') # ‹
- assert_raise(Encoding::UndefinedConversionError) { "\x8C".encode("utf-8", 'windows-1255') }
- assert_raise(Encoding::UndefinedConversionError) { "\x8F".encode("utf-8", 'windows-1255') }
- assert_raise(Encoding::UndefinedConversionError) { "\x90".encode("utf-8", 'windows-1255') }
- check_both_ways("\u2018", "\x91", 'windows-1255') # ‘
- check_both_ways("\u2122", "\x99", 'windows-1255') # ™
- assert_raise(Encoding::UndefinedConversionError) { "\x9A".encode("utf-8", 'windows-1255') }
- check_both_ways("\u203A", "\x9B", 'windows-1255') # ›
- assert_raise(Encoding::UndefinedConversionError) { "\x9C".encode("utf-8", 'windows-1255') }
- assert_raise(Encoding::UndefinedConversionError) { "\x9F".encode("utf-8", 'windows-1255') }
- check_both_ways("\u00A0", "\xA0", 'windows-1255') # non-breaking space
- check_both_ways("\u00A1", "\xA1", 'windows-1255') # ¡
- check_both_ways("\u00D7", "\xAA", 'windows-1255') # ×
- check_both_ways("\u00AF", "\xAF", 'windows-1255') # ¯
- check_both_ways("\u00B0", "\xB0", 'windows-1255') # °
- check_both_ways("\u00B8", "\xB8", 'windows-1255') # ¸
- check_both_ways("\u00F7", "\xBA", 'windows-1255') # ÷
- check_both_ways("\u00BF", "\xBF", 'windows-1255') # ¿
- check_both_ways("\u05B0", "\xC0", 'windows-1255') # ְ
- check_both_ways("\u05B9", "\xC9", 'windows-1255') # ֹ
- check_both_ways("\u05BA", "\xCA", 'windows-1255') # ֺ
- check_both_ways("\u05BB", "\xCB", 'windows-1255') # ֻ
- check_both_ways("\u05BF", "\xCF", 'windows-1255') # ֿ
- check_both_ways("\u05C0", "\xD0", 'windows-1255') # ׀
- check_both_ways("\u05F3", "\xD7", 'windows-1255') # ׳
- check_both_ways("\u05F4", "\xD8", 'windows-1255') # ״
- assert_raise(Encoding::UndefinedConversionError) { "\xD9".encode("utf-8", 'windows-1255') }
- assert_raise(Encoding::UndefinedConversionError) { "\xDF".encode("utf-8", 'windows-1255') }
- check_both_ways("\u05D0", "\xE0", 'windows-1255') # א
- check_both_ways("\u05DF", "\xEF", 'windows-1255') # ן
- check_both_ways("\u05E0", "\xF0", 'windows-1255') # נ
- check_both_ways("\u05EA", "\xFA", 'windows-1255') # ת
- assert_raise(Encoding::UndefinedConversionError) { "\xFB".encode("utf-8", 'windows-1255') }
- assert_raise(Encoding::UndefinedConversionError) { "\xFC".encode("utf-8", 'windows-1255') }
- check_both_ways("\u200E", "\xFD", 'windows-1255') # left-to-right mark
- check_both_ways("\u200F", "\xFE", 'windows-1255') # right-to-left mark
- assert_raise(Encoding::UndefinedConversionError) { "\xFF".encode("utf-8", 'windows-1255') }
- end
- def test_windows_1256
- check_both_ways("\u20AC", "\x80", 'windows-1256') # €
- check_both_ways("\u0679", "\x8A", 'windows-1256') # ٹ
- check_both_ways("\u0688", "\x8F", 'windows-1256') # ڈ
- check_both_ways("\u06AF", "\x90", 'windows-1256') # گ
- check_both_ways("\u06A9", "\x98", 'windows-1256') # ک
- check_both_ways("\u0691", "\x9A", 'windows-1256') # ڑ
- check_both_ways("\u06BA", "\x9F", 'windows-1256') # ں
- check_both_ways("\u00A0", "\xA0", 'windows-1256') # non-breaking space
- check_both_ways("\u06BE", "\xAA", 'windows-1256') # ھ
- check_both_ways("\u00AF", "\xAF", 'windows-1256') # ¯
- check_both_ways("\u00B0", "\xB0", 'windows-1256') # °
- check_both_ways("\u061F", "\xBF", 'windows-1256') # ؟
- check_both_ways("\u06C1", "\xC0", 'windows-1256') # ہ
- check_both_ways("\u062F", "\xCF", 'windows-1256') # د
- check_both_ways("\u0630", "\xD0", 'windows-1256') # ذ
- check_both_ways("\u0643", "\xDF", 'windows-1256') # ك
- check_both_ways("\u00E0", "\xE0", 'windows-1256') # à
- check_both_ways("\u00EF", "\xEF", 'windows-1256') # ï
- check_both_ways("\u064B", "\xF0", 'windows-1256') # ًً
- check_both_ways("\u06D2", "\xFF", 'windows-1256') # ے
- end
- def test_windows_1257
- check_both_ways("\u20AC", "\x80", 'windows-1257') # €
- assert_raise(Encoding::UndefinedConversionError) { "\x81".encode("utf-8", 'windows-1257') }
- check_both_ways("\u201A", "\x82", 'windows-1257') # ‚
- assert_raise(Encoding::UndefinedConversionError) { "\x83".encode("utf-8", 'windows-1257') }
- check_both_ways("\u201E", "\x84", 'windows-1257') # „
- check_both_ways("\u2021", "\x87", 'windows-1257') # ‡
- assert_raise(Encoding::UndefinedConversionError) { "\x88".encode("utf-8", 'windows-1257') }
- check_both_ways("\u2030", "\x89", 'windows-1257') # ‰
- assert_raise(Encoding::UndefinedConversionError) { "\x8A".encode("utf-8", 'windows-1257') }
- check_both_ways("\u2039", "\x8B", 'windows-1257') # ‹
- assert_raise(Encoding::UndefinedConversionError) { "\x8C".encode("utf-8", 'windows-1257') }
- check_both_ways("\u00A8", "\x8D", 'windows-1257') # ¨
- check_both_ways("\u02C7", "\x8E", 'windows-1257') # ˇ
- check_both_ways("\u00B8", "\x8F", 'windows-1257') # ¸
- assert_raise(Encoding::UndefinedConversionError) { "\x90".encode("utf-8", 'windows-1257') }
- check_both_ways("\u2018", "\x91", 'windows-1257') # ‘
- check_both_ways("\u2014", "\x97", 'windows-1257') # —
- assert_raise(Encoding::UndefinedConversionError) { "\x98".encode("utf-8", 'windows-1257') }
- check_both_ways("\u2122", "\x99", 'windows-1257') # ™
- assert_raise(Encoding::UndefinedConversionError) { "\x9A".encode("utf-8", 'windows-1257') }
- check_both_ways("\u203A", "\x9B", 'windows-1257') # ›
- assert_raise(Encoding::UndefinedConversionError) { "\x9C".encode("utf-8", 'windows-1257') }
- check_both_ways("\u00AF", "\x9D", 'windows-1257') # ¯
- check_both_ways("\u02DB", "\x9E", 'windows-1257') # ˛
- assert_raise(Encoding::UndefinedConversionError) { "\x9F".encode("utf-8", 'windows-1257') }
- check_both_ways("\u00A0", "\xA0", 'windows-1257') # non-breaking space
- assert_raise(Encoding::UndefinedConversionError) { "\xA1".encode("utf-8", 'windows-1257') }
- check_both_ways("\u00A2", "\xA2", 'windows-1257') # ¢
- check_both_ways("\u00A4", "\xA4", 'windows-1257') # ¤
- assert_raise(Encoding::UndefinedConversionError) { "\xA5".encode("utf-8", 'windows-1257') }
- check_both_ways("\u00A6", "\xA6", 'windows-1257') # ¦
- check_both_ways("\u00C6", "\xAF", 'windows-1257') # Æ
- check_both_ways("\u00B0", "\xB0", 'windows-1257') # °
- check_both_ways("\u00E6", "\xBF", 'windows-1257') # æ
- check_both_ways("\u0104", "\xC0", 'windows-1257') # Ą
- check_both_ways("\u013B", "\xCF", 'windows-1257') # Ļ
- check_both_ways("\u0160", "\xD0", 'windows-1257') # Š
- check_both_ways("\u00DF", "\xDF", 'windows-1257') # ß
- check_both_ways("\u0105", "\xE0", 'windows-1257') # ą
- check_both_ways("\u013C", "\xEF", 'windows-1257') # ļ
- check_both_ways("\u0161", "\xF0", 'windows-1257') # š
- check_both_ways("\u02D9", "\xFF", 'windows-1257') # ˙
- end
- def test_IBM437
- check_both_ways("\u00C7", "\x80", 'IBM437') # Ç
- check_both_ways("\u00C5", "\x8F", 'IBM437') # Å
- check_both_ways("\u00C9", "\x90", 'IBM437') # É
- check_both_ways("\u0192", "\x9F", 'IBM437') # ƒ
- check_both_ways("\u00E1", "\xA0", 'IBM437') # á
- check_both_ways("\u00BB", "\xAF", 'IBM437') # »
- check_both_ways("\u2591", "\xB0", 'IBM437') # ░
- check_both_ways("\u2510", "\xBF", 'IBM437') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM437') # └
- check_both_ways("\u2567", "\xCF", 'IBM437') # ╧
- check_both_ways("\u2568", "\xD0", 'IBM437') # ╨
- check_both_ways("\u2580", "\xDF", 'IBM437') # ▀
- check_both_ways("\u03B1", "\xE0", 'IBM437') # α
- check_both_ways("\u2229", "\xEF", 'IBM437') # ∩
- check_both_ways("\u2261", "\xF0", 'IBM437') # ≡
- check_both_ways("\u00A0", "\xFF", 'IBM437') # non-breaking space
- end
- def test_IBM775
- check_both_ways("\u0106", "\x80", 'IBM775') # Ć
- check_both_ways("\u00C5", "\x8F", 'IBM775') # Å
- check_both_ways("\u00C9", "\x90", 'IBM775') # É
- check_both_ways("\u00A4", "\x9F", 'IBM775') # ¤
- check_both_ways("\u0100", "\xA0", 'IBM775') # Ā
- check_both_ways("\u00BB", "\xAF", 'IBM775') # »
- check_both_ways("\u2591", "\xB0", 'IBM775') # ░
- check_both_ways("\u2510", "\xBF", 'IBM775') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM775') # └
- check_both_ways("\u017D", "\xCF", 'IBM775') # Ž
- check_both_ways("\u0105", "\xD0", 'IBM775') # ą
- check_both_ways("\u2580", "\xDF", 'IBM775') # ▀
- check_both_ways("\u00D3", "\xE0", 'IBM775') # Ó
- check_both_ways("\u2019", "\xEF", 'IBM775') # ’
- check_both_ways("\u00AD", "\xF0", 'IBM775') # soft hyphen
- check_both_ways("\u00A0", "\xFF", 'IBM775') # non-breaking space
- end
- def test_IBM852
- check_both_ways("\u00C7", "\x80", 'IBM852') # Ç
- check_both_ways("\u0106", "\x8F", 'IBM852') # Ć
- check_both_ways("\u00C9", "\x90", 'IBM852') # É
- check_both_ways("\u010D", "\x9F", 'IBM852') # č
- check_both_ways("\u00E1", "\xA0", 'IBM852') # á
- check_both_ways("\u00BB", "\xAF", 'IBM852') # »
- check_both_ways("\u2591", "\xB0", 'IBM852') # ░
- check_both_ways("\u2510", "\xBF", 'IBM852') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM852') # └
- check_both_ways("\u00A4", "\xCF", 'IBM852') # ¤
- check_both_ways("\u0111", "\xD0", 'IBM852') # đ
- check_both_ways("\u2580", "\xDF", 'IBM852') # ▀
- check_both_ways("\u00D3", "\xE0", 'IBM852') # Ó
- check_both_ways("\u00B4", "\xEF", 'IBM852') # ´
- check_both_ways("\u00AD", "\xF0", 'IBM852') # soft hyphen
- check_both_ways("\u00A0", "\xFF", 'IBM852') # non-breaking space
- end
- def test_IBM855
- check_both_ways("\u0452", "\x80", 'IBM855') # ђ
- check_both_ways("\u0408", "\x8F", 'IBM855') # Ј
- check_both_ways("\u0459", "\x90", 'IBM855') # љ
- check_both_ways("\u042A", "\x9F", 'IBM855') # Ъ
- check_both_ways("\u0430", "\xA0", 'IBM855') # а
- check_both_ways("\u00BB", "\xAF", 'IBM855') # »
- check_both_ways("\u2591", "\xB0", 'IBM855') # ░
- check_both_ways("\u2510", "\xBF", 'IBM855') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM855') # └
- check_both_ways("\u00A4", "\xCF", 'IBM855') # ¤
- check_both_ways("\u043B", "\xD0", 'IBM855') # л
- check_both_ways("\u2580", "\xDF", 'IBM855') # ▀
- check_both_ways("\u042F", "\xE0", 'IBM855') # Я
- check_both_ways("\u2116", "\xEF", 'IBM855') # №
- check_both_ways("\u00AD", "\xF0", 'IBM855') # soft hyphen
- check_both_ways("\u00A0", "\xFF", 'IBM855') # non-breaking space
- end
- def test_IBM857
- check_both_ways("\u00C7", "\x80", 'IBM857') # Ç
- check_both_ways("\u00C5", "\x8F", 'IBM857') # Å
- check_both_ways("\u00C9", "\x90", 'IBM857') # É
- check_both_ways("\u015F", "\x9F", 'IBM857') # ş
- check_both_ways("\u00E1", "\xA0", 'IBM857') # á
- check_both_ways("\u00BB", "\xAF", 'IBM857') # »
- check_both_ways("\u2591", "\xB0", 'IBM857') # ░
- check_both_ways("\u2510", "\xBF", 'IBM857') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM857') # └
- check_both_ways("\u00A4", "\xCF", 'IBM857') # ¤
- check_both_ways("\u00BA", "\xD0", 'IBM857') # º
- check_both_ways("\u00C8", "\xD4", 'IBM857') # È
- assert_raise(Encoding::UndefinedConversionError) { "\xD5".encode("utf-8", 'IBM857') }
- check_both_ways("\u00CD", "\xD6", 'IBM857') # Í
- check_both_ways("\u2580", "\xDF", 'IBM857') # ▀
- check_both_ways("\u00D3", "\xE0", 'IBM857') # Ó
- check_both_ways("\u00B5", "\xE6", 'IBM857') # µ
- assert_raise(Encoding::UndefinedConversionError) { "\xE7".encode("utf-8", 'IBM857') }
- check_both_ways("\u00D7", "\xE8", 'IBM857') # ×
- check_both_ways("\u00B4", "\xEF", 'IBM857') # ´
- check_both_ways("\u00AD", "\xF0", 'IBM857') # soft hyphen
- check_both_ways("\u00B1", "\xF1", 'IBM857') # ±
- assert_raise(Encoding::UndefinedConversionError) { "\xF2".encode("utf-8", 'IBM857') }
- check_both_ways("\u00BE", "\xF3", 'IBM857') # ¾
- check_both_ways("\u00A0", "\xFF", 'IBM857') # non-breaking space
- end
- def test_IBM860
- check_both_ways("\u00C7", "\x80", 'IBM860') # Ç
- check_both_ways("\u00C2", "\x8F", 'IBM860') # Â
- check_both_ways("\u00C9", "\x90", 'IBM860') # É
- check_both_ways("\u00D3", "\x9F", 'IBM860') # Ó
- check_both_ways("\u00E1", "\xA0", 'IBM860') # á
- check_both_ways("\u00BB", "\xAF", 'IBM860') # »
- check_both_ways("\u2591", "\xB0", 'IBM860') # ░
- check_both_ways("\u2510", "\xBF", 'IBM860') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM860') # └
- check_both_ways("\u2567", "\xCF", 'IBM860') # ╧
- check_both_ways("\u2568", "\xD0", 'IBM860') # ╨
- check_both_ways("\u2580", "\xDF", 'IBM860') # ▀
- check_both_ways("\u03B1", "\xE0", 'IBM860') # α
- check_both_ways("\u2229", "\xEF", 'IBM860') # ∩
- check_both_ways("\u2261", "\xF0", 'IBM860') # ≡
- check_both_ways("\u00A0", "\xFF", 'IBM860') # non-breaking space
- end
- def test_IBM861
- check_both_ways("\u00C7", "\x80", 'IBM861') # Ç
- check_both_ways("\u00C5", "\x8F", 'IBM861') # Å
- check_both_ways("\u00C9", "\x90", 'IBM861') # É
- check_both_ways("\u0192", "\x9F", 'IBM861') # ƒ
- check_both_ways("\u00E1", "\xA0", 'IBM861') # á
- check_both_ways("\u00BB", "\xAF", 'IBM861') # »
- check_both_ways("\u2591", "\xB0", 'IBM861') # ░
- check_both_ways("\u2510", "\xBF", 'IBM861') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM861') # └
- check_both_ways("\u2567", "\xCF", 'IBM861') # ╧
- check_both_ways("\u2568", "\xD0", 'IBM861') # ╨
- check_both_ways("\u2580", "\xDF", 'IBM861') # ▀
- check_both_ways("\u03B1", "\xE0", 'IBM861') # α
- check_both_ways("\u2229", "\xEF", 'IBM861') # ∩
- check_both_ways("\u2261", "\xF0", 'IBM861') # ≡
- check_both_ways("\u00A0", "\xFF", 'IBM861') # non-breaking space
- end
- def test_IBM862
- check_both_ways("\u05D0", "\x80", 'IBM862') # א
- check_both_ways("\u05DF", "\x8F", 'IBM862') # ן
- check_both_ways("\u05E0", "\x90", 'IBM862') # נ
- check_both_ways("\u0192", "\x9F", 'IBM862') # ƒ
- check_both_ways("\u00E1", "\xA0", 'IBM862') # á
- check_both_ways("\u00BB", "\xAF", 'IBM862') # »
- check_both_ways("\u2591", "\xB0", 'IBM862') # ░
- check_both_ways("\u2510", "\xBF", 'IBM862') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM862') # └
- check_both_ways("\u2567", "\xCF", 'IBM862') # ╧
- check_both_ways("\u2568", "\xD0", 'IBM862') # ╨
- check_both_ways("\u2580", "\xDF", 'IBM862') # ▀
- check_both_ways("\u03B1", "\xE0", 'IBM862') # α
- check_both_ways("\u2229", "\xEF", 'IBM862') # ∩
- check_both_ways("\u2261", "\xF0", 'IBM862') # ≡
- check_both_ways("\u00A0", "\xFF", 'IBM862') # non-breaking space
- end
- def test_IBM863
- check_both_ways("\u00C7", "\x80", 'IBM863') # Ç
- check_both_ways("\u00A7", "\x8F", 'IBM863') # §
- check_both_ways("\u00C9", "\x90", 'IBM863') # É
- check_both_ways("\u0192", "\x9F", 'IBM863') # ƒ
- check_both_ways("\u00A6", "\xA0", 'IBM863') # ¦
- check_both_ways("\u00BB", "\xAF", 'IBM863') # »
- check_both_ways("\u2591", "\xB0", 'IBM863') # ░
- check_both_ways("\u2510", "\xBF", 'IBM863') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM863') # └
- check_both_ways("\u2567", "\xCF", 'IBM863') # ╧
- check_both_ways("\u2568", "\xD0", 'IBM863') # ╨
- check_both_ways("\u2580", "\xDF", 'IBM863') # ▀
- check_both_ways("\u03B1", "\xE0", 'IBM863') # α
- check_both_ways("\u2229", "\xEF", 'IBM863') # ∩
- check_both_ways("\u2261", "\xF0", 'IBM863') # ≡
- check_both_ways("\u00A0", "\xFF", 'IBM863') # non-breaking space
- end
- def test_IBM865
- check_both_ways("\u00C7", "\x80", 'IBM865') # Ç
- check_both_ways("\u00C5", "\x8F", 'IBM865') # Å
- check_both_ways("\u00C9", "\x90", 'IBM865') # É
- check_both_ways("\u0192", "\x9F", 'IBM865') # ƒ
- check_both_ways("\u00E1", "\xA0", 'IBM865') # á
- check_both_ways("\u00A4", "\xAF", 'IBM865') # ¤
- check_both_ways("\u2591", "\xB0", 'IBM865') # ░
- check_both_ways("\u2510", "\xBF", 'IBM865') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM865') # └
- check_both_ways("\u2567", "\xCF", 'IBM865') # ╧
- check_both_ways("\u2568", "\xD0", 'IBM865') # ╨
- check_both_ways("\u2580", "\xDF", 'IBM865') # ▀
- check_both_ways("\u03B1", "\xE0", 'IBM865') # α
- check_both_ways("\u2229", "\xEF", 'IBM865') # ∩
- check_both_ways("\u2261", "\xF0", 'IBM865') # ≡
- check_both_ways("\u00A0", "\xFF", 'IBM865') # non-breaking space
- end
- def test_IBM866
- check_both_ways("\u0410", "\x80", 'IBM866') # А
- check_both_ways("\u041F", "\x8F", 'IBM866') # П
- check_both_ways("\u0420", "\x90", 'IBM866') # Р
- check_both_ways("\u042F", "\x9F", 'IBM866') # Я
- check_both_ways("\u0430", "\xA0", 'IBM866') # а
- check_both_ways("\u043F", "\xAF", 'IBM866') # п
- check_both_ways("\u2591", "\xB0", 'IBM866') # ░
- check_both_ways("\u2510", "\xBF", 'IBM866') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM866') # └
- check_both_ways("\u2567", "\xCF", 'IBM866') # ╧
- check_both_ways("\u2568", "\xD0", 'IBM866') # ╨
- check_both_ways("\u2580", "\xDF", 'IBM866') # ▀
- check_both_ways("\u0440", "\xE0", 'IBM866') # р
- check_both_ways("\u044F", "\xEF", 'IBM866') # я
- check_both_ways("\u0401", "\xF0", 'IBM866') # Ё
- check_both_ways("\u00A0", "\xFF", 'IBM866') # non-breaking space
- end
- def test_IBM869
- assert_raise(Encoding::UndefinedConversionError) { "\x80".encode("utf-8", 'IBM869') }
- assert_raise(Encoding::UndefinedConversionError) { "\x85".encode("utf-8", 'IBM869') }
- check_both_ways("\u0386", "\x86", 'IBM869') # Ά
- assert_raise(Encoding::UndefinedConversionError) { "\x87".encode("utf-8", 'IBM869') }
- check_both_ways("\u00B7", "\x88", 'IBM869') # ·
- check_both_ways("\u0389", "\x8F", 'IBM869') # Ή
- check_both_ways("\u038A", "\x90", 'IBM869') # Ί
- check_both_ways("\u038C", "\x92", 'IBM869') # Ό
- assert_raise(Encoding::UndefinedConversionError) { "\x93".encode("utf-8", 'IBM869') }
- assert_raise(Encoding::UndefinedConversionError) { "\x94".encode("utf-8", 'IBM869') }
- check_both_ways("\u038E", "\x95", 'IBM869') # Ύ
- check_both_ways("\u03AF", "\x9F", 'IBM869') # ί
- check_both_ways("\u03CA", "\xA0", 'IBM869') # ϊ
- check_both_ways("\u00BB", "\xAF", 'IBM869') # »
- check_both_ways("\u2591", "\xB0", 'IBM869') # ░
- check_both_ways("\u2510", "\xBF", 'IBM869') # ┐
- check_both_ways("\u2514", "\xC0", 'IBM869') # └
- check_both_ways("\u03A3", "\xCF", 'IBM869') # Σ
- check_both_ways("\u03A4", "\xD0", 'IBM869') # Τ
- check_both_ways("\u2580", "\xDF", 'IBM869') # ▀
- check_both_ways("\u03B6", "\xE0", 'IBM869') # ζ
- check_both_ways("\u0384", "\xEF", 'IBM869') # ΄
- check_both_ways("\u00AD", "\xF0", 'IBM869') # soft hyphen
- check_both_ways("\u00A0", "\xFF", 'IBM869') # non-breaking space
- end
- def test_macCroatian
- check_both_ways("\u00C4", "\x80", 'macCroatian') # Ä
- check_both_ways("\u00E8", "\x8F", 'macCroatian') # è
- check_both_ways("\u00EA", "\x90", 'macCroatian') # ê
- check_both_ways("\u00FC", "\x9F", 'macCroatian') # ü
- check_both_ways("\u2020", "\xA0", 'macCroatian') # †
- check_both_ways("\u00D8", "\xAF", 'macCroatian') # Ø
- check_both_ways("\u221E", "\xB0", 'macCroatian') # ∞
- check_both_ways("\u00F8", "\xBF", 'macCroatian') # ø
- check_both_ways("\u00BF", "\xC0", 'macCroatian') # ¿
- check_both_ways("\u0153", "\xCF", 'macCroatian') # œ
- check_both_ways("\u0110", "\xD0", 'macCroatian') # Đ
- check_both_ways("\u00A9", "\xD9", 'macCroatian') # ©
- check_both_ways("\u2044", "\xDA", 'macCroatian') # ⁄
- check_both_ways("\u203A", "\xDD", 'macCroatian') # ›
- check_both_ways("\u00C6", "\xDE", 'macCroatian') # Æ
- check_both_ways("\u00BB", "\xDF", 'macCroatian') # »
- check_both_ways("\u2013", "\xE0", 'macCroatian') # –
- check_both_ways("\u00B7", "\xE1", 'macCroatian') # ·
- check_both_ways("\u00C2", "\xE5", 'macCroatian') # Â
- check_both_ways("\u0107", "\xE6", 'macCroatian') # ć
- check_both_ways("\u00C1", "\xE7", 'macCroatian') # Á
- check_both_ways("\u010D", "\xE8", 'macCroatian') # č
- check_both_ways("\u00C8", "\xE9", 'macCroatian') # È
- check_both_ways("\u00D4", "\xEF", 'macCroatian') # Ô
- check_both_ways("\u0111", "\xF0", 'macCroatian') # đ
- check_both_ways("\u00D2", "\xF1", 'macCroatian') # Ò
- check_both_ways("\u00AF", "\xF8", 'macCroatian') # ¯
- check_both_ways("\u03C0", "\xF9", 'macCroatian') # π
- check_both_ways("\u00CB", "\xFA", 'macCroatian') # Ë
- check_both_ways("\u00CA", "\xFD", 'macCroatian') # Ê
- check_both_ways("\u00E6", "\xFE", 'macCroatian') # æ
- check_both_ways("\u02C7", "\xFF", 'macCroatian') # ˇ
- end
- def test_macCyrillic
- check_both_ways("\u0410", "\x80", 'macCyrillic') # А
- check_both_ways("\u041F", "\x8F", 'macCyrillic') # П
- check_both_ways("\u0420", "\x90", 'macCyrillic') # Р
- check_both_ways("\u042F", "\x9F", 'macCyrillic') # Я
- check_both_ways("\u2020", "\xA0", 'macCyrillic') # †
- check_both_ways("\u0453", "\xAF", 'macCyrillic') # ѓ
- check_both_ways("\u221E", "\xB0", 'macCyrillic') # ∞
- check_both_ways("\u045A", "\xBF", 'macCyrillic') # њ
- check_both_ways("\u0458", "\xC0", 'macCyrillic') # ј
- check_both_ways("\u0455", "\xCF", 'macCyrillic') # ѕ
- check_both_ways("\u2013", "\xD0", 'macCyrillic') # –
- check_both_ways("\u044F", "\xDF", 'macCyrillic') # я
- check_both_ways("\u0430", "\xE0", 'macCyrillic') # а
- check_both_ways("\u043F", "\xEF", 'macCyrillic') # п
- check_both_ways("\u0440", "\xF0", 'macCyrillic') # р
- check_both_ways("\u00A4", "\xFF", 'macCyrillic') # ¤
- end
- def test_macGreek
- check_both_ways("\u00C4", "\x80", 'macGreek') # Ä
- check_both_ways("\u00E8", "\x8F", 'macGreek') # è
- check_both_ways("\u00EA", "\x90", 'macGreek') # ê
- check_both_ways("\u00FC", "\x9F", 'macGreek') # ü
- check_both_ways("\u2020", "\xA0", 'macGreek') # †
- check_both_ways("\u0393", "\xA1", 'macGreek') # Γ
- check_both_ways("\u0387", "\xAF", 'macGreek') # ·
- check_both_ways("\u0391", "\xB0", 'macGreek') # Α
- check_both_ways("\u03A9", "\xBF", 'macGreek') # Ω
- check_both_ways("\u03AC", "\xC0", 'macGreek') # ά
- check_both_ways("\u0153", "\xCF", 'macGreek') # œ
- check_both_ways("\u2013", "\xD0", 'macGreek') # –
- check_both_ways("\u038F", "\xDF", 'macGreek') # Ώ
- check_both_ways("\u03CD", "\xE0", 'macGreek') # ύ
- check_both_ways("\u03BF", "\xEF", 'macGreek') # ο
- check_both_ways("\u03C0", "\xF0", 'macGreek') # π
- check_both_ways("\u03B0", "\xFE", 'macGreek') # ΰ
- assert_raise(Encoding::UndefinedConversionError) { "\xFF".encode("utf-8", 'macGreek') }
- end
- def test_macIceland
- check_both_ways("\u00C4", "\x80", 'macIceland') # Ä
- check_both_ways("\u00E8", "\x8F", 'macIceland') # è
- check_both_ways("\u00EA", "\x90", 'macIceland') # ê
- check_both_ways("\u00FC", "\x9F", 'macIceland') # ü
- check_both_ways("\u00DD", "\xA0", 'macIceland') # Ý
- check_both_ways("\u00D8", "\xAF", 'macIceland') # Ø
- check_both_ways("\u221E", "\xB0", 'macIceland') # ∞
- check_both_ways("\u00F8", "\xBF", 'macIceland') # ø
- check_both_ways("\u00BF", "\xC0", 'macIceland') # ¿
- check_both_ways("\u0153", "\xCF", 'macIceland') # œ
- check_both_ways("\u2013", "\xD0", 'macIceland') # –
- check_both_ways("\u00FE", "\xDF", 'macIceland') # þ
- check_both_ways("\u00FD", "\xE0", 'macIceland') # ý
- check_both_ways("\u00D4", "\xEF", 'macIceland') # Ô
- #check_both_ways("\uF8FF", "\xF0", 'macIceland') # Apple logo
- check_both_ways("\u02C7", "\xFF", 'macIceland') # ˇ
- end
- def test_macRoman
- check_both_ways("\u00C4", "\x80", 'macRoman') # Ä
- check_both_ways("\u00E8", "\x8F", 'macRoman') # è
- check_both_ways("\u00EA", "\x90", 'macRoman') # ê
- check_both_ways("\u00FC", "\x9F", 'macRoman') # ü
- check_both_ways("\u2020", "\xA0", 'macRoman') # †
- #check_both_ways("\u00DB", "\xAF", 'macRoman') # Ø
- check_both_ways("\u221E", "\xB0", 'macRoman') # ∞
- check_both_ways("\u00F8", "\xBF", 'macRoman') # ø
- check_both_ways("\u00BF", "\xC0", 'macRoman') # ¿
- check_both_ways("\u0153", "\xCF", 'macRoman') # œ
- check_both_ways("\u2013", "\xD0", 'macRoman') # –
- check_both_ways("\u00A4", "\xDB", 'macRoman') # ¤
- check_both_ways("\uFB02", "\xDF", 'macRoman') # fl
- check_both_ways("\u2021", "\xE0", 'macRoman') # ‡
- check_both_ways("\u00D4", "\xEF", 'macRoman') # Ô
- #check_both_ways("\uF8FF", "\xF0", 'macRoman') # Apple logo
- check_both_ways("\u02C7", "\xFF", 'macRoman') # ˇ
- end
- def test_macRomania
- check_both_ways("\u00C4", "\x80", 'macRomania') # Ä
- check_both_ways("\u00E8", "\x8F", 'macRomania') # è
- check_both_ways("\u00EA", "\x90", 'macRomania') # ê
- check_both_ways("\u00FC", "\x9F", 'macRomania') # ü
- check_both_ways("\u2020", "\xA0", 'macRomania') # †
- check_both_ways("\u015E", "\xAF", 'macRomania') # Ş
- check_both_ways("\u221E", "\xB0", 'macRomania') # ∞
- check_both_ways("\u015F", "\xBF", 'macRomania') # ş
- check_both_ways("\u00BF", "\xC0", 'macRomania') # ¿
- check_both_ways("\u0153", "\xCF", 'macRomania') # œ
- check_both_ways("\u2013", "\xD0", 'macRomania') # –
- check_both_ways("\u00A4", "\xDB", 'macRomania') # €
- check_both_ways("\u0163", "\xDF", 'macRomania') # ţ
- check_both_ways("\u2021", "\xE0", 'macRomania') # ‡
- check_both_ways("\u00D4", "\xEF", 'macRomania') # Ô
- #check_both_ways("\uF8FF", "\xF0", 'macRomania') # Apple logo
- check_both_ways("\u02C7", "\xFF", 'macRomania') # ˇ
- end
- def test_macTurkish
- check_both_ways("\u00C4", "\x80", 'macTurkish') # Ä
- check_both_ways("\u00E8", "\x8F", 'macTurkish') # è
- check_both_ways("\u00EA", "\x90", 'macTurkish') # ê
- check_both_ways("\u00FC", "\x9F", 'macTurkish') # ü
- check_both_ways("\u2020", "\xA0", 'macTurkish') # †
- check_both_ways("\u00D8", "\xAF", 'macTurkish') # Ø
- check_both_ways("\u221E", "\xB0", 'macTurkish') # ∞
- check_both_ways("\u00F8", "\xBF", 'macTurkish') # ø
- check_both_ways("\u00BF", "\xC0", 'macTurkish') # ¿
- check_both_ways("\u0153", "\xCF", 'macTurkish') # œ
- check_both_ways("\u2013", "\xD0", 'macTurkish') # –
- check_both_ways("\u015F", "\xDF", 'macTurkish') # ş
- check_both_ways("\u2021", "\xE0", 'macTurkish') # ‡
- check_both_ways("\u00D4", "\xEF", 'macTurkish') # Ô
- #check_both_ways("\uF8FF", "\xF0", 'macTurkish') # Apple logo
- check_both_ways("\u00D9", "\xF4", 'macTurkish') # Ù
- assert_raise(Encoding::UndefinedConversionError) { "\xF5".encode("utf-8", 'macTurkish') }
- check_both_ways("\u02C6", "\xF6", 'macTurkish') # ˆ
- check_both_ways("\u02C7", "\xFF", 'macTurkish') # ˇ
- end
- def test_macUkraine
- check_both_ways("\u0410", "\x80", 'macUkraine') # А
- check_both_ways("\u041F", "\x8F", 'macUkraine') # П
- check_both_ways("\u0420", "\x90", 'macUkraine') # Р
- check_both_ways("\u042F", "\x9F", 'macUkraine') # Я
- check_both_ways("\u2020", "\xA0", 'macUkraine') # †
- check_both_ways("\u0453", "\xAF", 'macUkraine') # ѓ
- check_both_ways("\u221E", "\xB0", 'macUkraine') # ∞
- check_both_ways("\u045A", "\xBF", 'macUkraine') # њ
- check_both_ways("\u0458", "\xC0", 'macUkraine') # ј
- check_both_ways("\u0455", "\xCF", 'macUkraine') # ѕ
- check_both_ways("\u2013", "\xD0", 'macUkraine') # –
- check_both_ways("\u044F", "\xDF", 'macUkraine') # я
- check_both_ways("\u0430", "\xE0", 'macUkraine') # а
- check_both_ways("\u043F", "\xEF", 'macUkraine') # п
- check_both_ways("\u0440", "\xF0", 'macUkraine') # р
- check_both_ways("\u00A4", "\xFF", 'macUkraine') # ¤
- end
- def test_koi8_u
- check_both_ways("\u2500", "\x80", 'KOI8-U') # ─
- check_both_ways("\u2590", "\x8F", 'KOI8-U') # ▐
- check_both_ways("\u2591", "\x90", 'KOI8-U') # ░
- check_both_ways("\u00F7", "\x9F", 'KOI8-U') # ÷
- check_both_ways("\u2550", "\xA0", 'KOI8-U') # ═
- check_both_ways("\u0454", "\xA4", 'KOI8-U') # є
- check_both_ways("\u0456", "\xA6", 'KOI8-U') # і
- check_both_ways("\u0457", "\xA7", 'KOI8-U') # ї
- check_both_ways("\u0491", "\xAD", 'KOI8-U') # ґ
- check_both_ways("\u255E", "\xAF", 'KOI8-U') # ╞
- check_both_ways("\u255F", "\xB0", 'KOI8-U') # ╟
- check_both_ways("\u0404", "\xB4", 'KOI8-U') # Є
- check_both_ways("\u0406", "\xB6", 'KOI8-U') # І
- check_both_ways("\u0407", "\xB7", 'KOI8-U') # Ї
- check_both_ways("\u0490", "\xBD", 'KOI8-U') # Ґ
- check_both_ways("\u00A9", "\xBF", 'KOI8-U') # ©
- check_both_ways("\u044E", "\xC0", 'KOI8-U') # ю
- check_both_ways("\u043E", "\xCF", 'KOI8-U') # о
- check_both_ways("\u043F", "\xD0", 'KOI8-U') # п
- check_both_ways("\u044A", "\xDF", 'KOI8-U') # ъ
- check_both_ways("\u042E", "\xE0", 'KOI8-U') # Ю
- check_both_ways("\u041E", "\xEF", 'KOI8-U') # О
- check_both_ways("\u041F", "\xF0", 'KOI8-U') # П
- check_both_ways("\u042A", "\xFF", 'KOI8-U') # Ъ
- end
- def test_koi8_r
- check_both_ways("\u2500", "\x80", 'KOI8-R') # ─
- check_both_ways("\u2590", "\x8F", 'KOI8-R') # ▐
- check_both_ways("\u2591", "\x90", 'KOI8-R') # ░
- check_both_ways("\u00F7", "\x9F", 'KOI8-R') # ÷
- check_both_ways("\u2550", "\xA0", 'KOI8-R') # ═
- check_both_ways("\u255E", "\xAF", 'KOI8-R') # ╞
- check_both_ways("\u255F", "\xB0", 'KOI8-R') # ╟
- check_both_ways("\u00A9", "\xBF", 'KOI8-R') # ©
- check_both_ways("\u044E", "\xC0", 'KOI8-R') # ю
- check_both_ways("\u043E", "\xCF", 'KOI8-R') # о
- check_both_ways("\u043F", "\xD0", 'KOI8-R') # п
- check_both_ways("\u044A", "\xDF", 'KOI8-R') # ъ
- check_both_ways("\u042E", "\xE0", 'KOI8-R') # Ю
- check_both_ways("\u041E", "\xEF", 'KOI8-R') # О
- check_both_ways("\u041F", "\xF0", 'KOI8-R') # П
- check_both_ways("\u042A", "\xFF", 'KOI8-R') # Ъ
- end
- def test_TIS_620
- assert_raise(Encoding::UndefinedConversionError) { "\x80".encode("utf-8", 'TIS-620') }
- assert_raise(Encoding::UndefinedConversionError) { "\x8F".encode("utf-8", 'TIS-620') }
- assert_raise(Encoding::UndefinedConversionError) { "\x90".encode("utf-8", 'TIS-620') }
- assert_raise(Encoding::Undef…