summaryrefslogtreecommitdiff
path: root/lib/gitlabhq/encode.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlabhq/encode.rb')
-rw-r--r--lib/gitlabhq/encode.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitlabhq/encode.rb b/lib/gitlabhq/encode.rb
new file mode 100644
index 00000000000..a493fb21192
--- /dev/null
+++ b/lib/gitlabhq/encode.rb
@@ -0,0 +1,14 @@
+module Gitlabhq
+ module Encode
+ extend self
+
+ def utf8 message
+ hash = CharlockHolmes::EncodingDetector.detect(message)
+ if hash[:encoding]
+ CharlockHolmes::Converter.convert(message, hash[:encoding], 'UTF-8')
+ else
+ message
+ end.force_encoding("utf-8")
+ end
+ end
+end