tc_encodings.rb 713 B

1234567891011121314151617181920212223
  1. #!/usr/local/bin/ruby -w
  2. # tc_encodings.rb
  3. #
  4. # Created by Michael Reinsch.
  5. # Copyright (c) 2012 Ubiquitous Business Technology, Inc.
  6. require "test/unit"
  7. require "faster_csv"
  8. class TestEncodings < Test::Unit::TestCase
  9. def test_with_shift_jis_encoding
  10. $KCODE = 'u' # make sure $KCODE != Shift_JIS
  11. # this test data will not work with UTF-8 encoding
  12. shift_jis_data = [ "82D082E782AA82C82094E0",
  13. "82D082E7826082AA825C",
  14. "82D082E7826082AA82C8" ].map { |f| [f].pack("H*") }
  15. fields = FCSV.parse_line( shift_jis_data.map { |f| %Q{"#{f}"} }.join(","),
  16. :encoding => "s" )
  17. assert_equal(shift_jis_data, fields)
  18. end
  19. end