Welcome to mirror list, hosted at ThFree Co, Russian Federation.

encode.rb « gitlabhq « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 55e86192ad464374896af7acc27d8af92a0d0aa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Gitlabhq
  module Encode 
    extend self

    def utf8 message
      return nil unless 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