2012-04-11 20:03:56 +00:00
|
|
|
module Gitlabhq
|
|
|
|
module Encode
|
|
|
|
extend self
|
|
|
|
|
|
|
|
def utf8 message
|
2012-05-21 20:17:41 +00:00
|
|
|
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
|