Convert latin1 string to utf8?
require 'iconv'i = Iconv.new('UTF-8','LATIN1')a_with_hat = i.iconv("\xc2")
Judging by your tags, I guess you want something like this:
require 'rubygems'require 'open-uri'require 'nokogiri'require 'iconv'file = open(your_uri)doc = Nokogiri::HTML(Iconv.conv('utf-8', 'latin1', file.readlines.join("\n")))doc.xpath(your_xpath)
If you're not sure what charset the uri uses, you can use file.charset
to get the charset instead of 'latin'
.