you can use RChardet library,

her'es what i use:

require 'rchardet'

class String
   def encoding
     @encoding ||= guess_encoding
   end

   def encoding=(new)
     @encoding = new
   end

   def convert_to(new)
     self.replace(Iconv.iconv(new, encoding, self)[0])
     @encoding = new
   end

   def guess_encoding
     @encoding = CharDet.guess(self)["encoding"]
   end

   # this enables "foo".convert :us-ascii => :utf8
   def convert(hash)
     from = hash.keys[0]
     to = hash[from]
     self.replace(Iconv.iconv(to, from, self)[0])
   end
end

it handles translating preatty well :)