encode.rb 324 Bytes
Newer Older
1 2 3 4 5
module Gitlabhq
  module Encode 
    extend self

    def utf8 message
6
      hash = CharlockHolmes::EncodingDetector.detect(message) rescue {}
7 8 9 10 11 12 13 14
      if hash[:encoding]
        CharlockHolmes::Converter.convert(message, hash[:encoding], 'UTF-8')
      else
        message
      end.force_encoding("utf-8")
    end
  end
end