Hi,

In message "Re: ruby 1.9 hates you and me and the encodings we rode in on so just get 	used to it."
    on Sat, 17 May 2008 06:10:05 +0900, DJ Jazzy Linefeed <john.d.perkins / gmail.com> writes:
|
|def prep_file(path)
|
|  ret = ''
|
|  x = File.open(path)
|
|  x.lines.each do |l|
|    l.gsub!('\n', ' ')
|    ret << l
|  end
|
|  puts ret
|
|end
|...
|compare.rb:64:in `gsub': broken UTF-8 string (ArgumentError)
|	from compare.rb:64:in `block in prep_file'
|	from compare.rb:63:in `each_line'
|	from compare.rb:63:in `call'
|	from compare.rb:63:in `each'
|	from compare.rb:63:in `prep_file'
|	from compare.rb:144:in `<main>'

Regular expression operation does not work fine on broken strings.  It
seems that you specify utf-8 for your locale, yet the content of
reading file is not.  If you know the encoding of the content, say
iso-8859-1, you can open it with the explicit encoding:

  x = File.open(path, "r:iso-8859-1")

if not, you can say it

  x = File.open(path, "r:ascii-8bit")

unless the file content is non ASCII like UTF-16.

							matz.