From: 7stud -- Date: 2011-07-21T13:57:26+09:00 Subject: Re: ArgumentError - invalid byte sequence in UTF-8 1) No matter what you do, there can always be an invalid byte sequence. 2) You have to know the encoding of a file to read it. #encoding: utf-8 puts RUBY_VERSION str = "m€, ¥ou" File.open('text.txt', 'w') do |f| f.puts str end IO.foreach('text.txt', 'r') do |line| p line.encoding.name p line end --output:-- 1.9.2 "UTF-8" "m€, ¥ou\n" -- Posted via http://www.ruby-forum.com/.