Broken UTF-8 string

begin
File.new(path_file,“r”).each { |line|
puts line
}
rescue
puts “Error read file #{subor}: #{$!}”
next
end

In Ruby 1.9: broken UTF-8 string
In Ruby 1.9.1: invalid byte sequence in UTF-8

Read files is mail in other codepage, example 1251, 1250 or 88952-2,
88592-1 utf-8

System is Debian or Archlinux.

Thx

Peter Eldo wrote:

begin
File.new(path_file,“r”).each { |line|
puts line
}
rescue
puts “Error read file #{subor}: #{$!}”
next
end

In Ruby 1.9: broken UTF-8 string
In Ruby 1.9.1: invalid byte sequence in UTF-8

Read files is mail in other codepage, example 1251, 1250 or 88952-2,
88592-1 utf-8

I believe you specify the encoding within the File.new(path_file, xxx)

viz:
http://stackoverflow.com/questions/1378185/how-to-specify-output-file-encoding-in-ruby

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs