diff options
author | Michael Koziarski <michael@koziarski.com> | 2006-10-17 08:29:16 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2006-10-17 08:29:16 +0000 |
commit | 911f3db00abb7b35b400973c032e4e5c340bce6f (patch) | |
tree | 7b8435b9160ed8b8d8e1a8ba537950685e915b23 /activesupport/test/multibyte_handler_test.rb | |
parent | 2d3367669156ec4149c8773a6afa93d220c36e7f (diff) | |
download | rails-911f3db00abb7b35b400973c032e4e5c340bce6f.tar.gz rails-911f3db00abb7b35b400973c032e4e5c340bce6f.tar.bz2 rails-911f3db00abb7b35b400973c032e4e5c340bce6f.zip |
Ensure Chars#tidy_bytes only tidies broken bytes. Closes #6397 [Manfred Stienstra]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5316 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/multibyte_handler_test.rb')
-rw-r--r-- | activesupport/test/multibyte_handler_test.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activesupport/test/multibyte_handler_test.rb b/activesupport/test/multibyte_handler_test.rb index 06bc904c04..95d6faec7c 100644 --- a/activesupport/test/multibyte_handler_test.rb +++ b/activesupport/test/multibyte_handler_test.rb @@ -228,7 +228,10 @@ module UTF8HandlingTest def test_tidy_bytes result = [0xb8, 0x17e, 0x8, 0x2c6, 0xa5].pack('U*') assert_equal result, @handler.tidy_bytes(@bytestring) - assert_equal "a#{result}a", @handler.tidy_bytes('a' + @bytestring + 'a') + assert_equal "a#{result}a", @handler.tidy_bytes('a' + @bytestring + 'a'), + 'tidy_bytes should leave surrounding characters intact' + assert_equal "é#{result}é", @handler.tidy_bytes('é' + @bytestring + 'é'), + 'tidy_bytes should leave surrounding characters intact' assert_nothing_raised { @handler.tidy_bytes(@bytestring).unpack('U*') } assert_equal "\xC3\xA7", @handler.tidy_bytes("\xE7") # iso_8859_1: small c cedilla @@ -236,7 +239,7 @@ module UTF8HandlingTest assert_equal "\xE2\x80\x9C", @handler.tidy_bytes("\x93") # win_1252: left smart quote assert_equal "\xE2\x82\xAC", @handler.tidy_bytes("\x80") # win_1252: euro assert_equal "\x00", @handler.tidy_bytes("\x00") # null char - assert_equal [0xef, 0xbf, 0xbd].pack('U*'), @handler.tidy_bytes("\xef\xbf\xbd") # invalid char + assert_equal [0xfffd].pack('U'), @handler.tidy_bytes("\xef\xbf\xbd") # invalid char end protected |