def string_encoder
      return string if string.valid_encoding?
      str = string
      Encoding.list.each do |e|
        begin
          str.force_encoding(e.name)
          tmp_string = str.encode('UTF-8')
          return tmp_string if tmp_string.valid_encoding?
        rescue
          Rails.logger.debug { "Rescue -> #{e.name}" } if defined?(::Rails)
        end
      end

      impossible_encoding

      string
    end
def string_encoder
      return string if string.valid_encoding?
      str = string
      Encoding.list.each do |e|
        begin
          str.force_encoding(e.name)
          tmp_string = str.encode('UTF-8')
          return tmp_string if tmp_string.valid_encoding?
        rescue
          Rails.logger.debug { "Rescue -> #{e.name}" } if defined?(::Rails)
        end
      end

      impossible_encoding

      string
    end
Funzione di encoding semplice