From: Patrick Roemer Date: 2008-02-18T22:54:58+09:00 Subject: Ruby 1.9, CSV and encodings Hi, I'd like to process an ISO-8859-1 encoded .csv file on a UTF-8 system using Ruby 1.9. The naive approach of using the CSV lib fails with "invalid mbstring sequence". I don't see where to specify the encoding. I've even tried the '--encoding' command line switch, but it doesn't seem to know ISO-8895-1 in all spellings I could come up with. (BTW, where is command line switch behavior like this documented in detail?) Currently I'm reading the complete file, enforce the encoding and process the in-memory string: file_content = IO.readlines(file_name).join file_content.force_encoding('ISO-8859-1') parser = CSV.new(file_content, ...) But that looks like a rather clumsy hack. What's the "right" way to do it? Thanks and best regards, Patrick