gitlabhq/lib/gitlabhq/encode.rb

15 lines
324 B
Ruby
Raw Normal View History

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