From: "Allan A." Date: 2012-09-02T04:01:31+09:00 Subject: Re: Beginner Help - Encoding error exporting/writing to CSV Bartosz DziewoƄski wrote in post #1074257: > Uh, that's certainly bad. Either you're not using Ruby 1.9 (that would > be weird...), or the objects you are operating on are not the object > you think they are (you should get information about the in the error > message, e.g. "NoMethodError: undefined method `encode' for > 5:Fixnum"). > It would just be like: postcontent.force_encoding('utf-8')) right? Or do I have to pass the output of that into another variable/string? This is what I get when I use the above: threads.rb:64:in `block in
': undefined method `force_encoding' for # (NoMethodError) from threads.rb:21:in `each' from threads.rb:21:in `
' > I skimmed the code, possible places where you are not setting the > encoding are "files = CSV.read("files1.csv")" or "doc = > Nokogiri::HTML(open(files[index][0]))". Also, this is a different code > than the one that gives the error in first post (there is not line 77 > in it). > Nope, it's the same code but the files1.csv has about 3000 lines/files in it. I presume it's failing on the postcontent on one of those in teh array. When I stick the force_encoding at the end of the Nokogiri call (since that's where the text is coming out from), I get: threads.rb:20:in `
': undefined method `force_encoding' for # (NoMethodError) -- Posted via http://www.ruby-forum.com/.