class Encoder
  def self.encode(string)
    if string.respond_to?(:encode!)
      string.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '')
    else
      require 'iconv'
      ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', string + ' ')[0..-2]
    end
  end
end

class Encoder
  def self.encode(string)
    if string.respond_to?(:encode!)
      string.encode!('UTF-8')
    else
      require 'iconv'
      ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', string + ' ')[0..-2]
    end
  end
end

Revert "Fix handing of unusual characters"
Revert "Fix handing of unusual characters"

This reverts commit 405d6f65b7573a182f0bf1f36e3ee9ca9b507561.
