summaryrefslogtreecommitdiff
path: root/lib/gitlabhq/encode.rb
blob: 11d9bd7bfd9f6b092664442e1de6830ea7876bc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module Gitlabhq
  module Encode 
    extend self

    def utf8 message
      hash = CharlockHolmes::EncodingDetector.detect(message) rescue {}
      if hash[:encoding]
        CharlockHolmes::Converter.convert(message, hash[:encoding], 'UTF-8')
      else
        message
      end.force_encoding("utf-8")
    end
  end
end