gitlab-org--gitlab-foss/lib/gitlabhq/encode.rb

17 lines
357 B
Ruby
Raw Normal View History

2012-04-11 20:03:56 +00:00
module Gitlabhq
module Encode
extend self
def utf8 message
return nil unless message
2012-04-24 10:41:20 +00:00
hash = CharlockHolmes::EncodingDetector.detect(message) rescue {}
2012-04-11 20:03:56 +00:00
if hash[:encoding]
CharlockHolmes::Converter.convert(message, hash[:encoding], 'UTF-8')
else
message
end.force_encoding("utf-8")
end
end
end