summaryrefslogtreecommitdiff
path: root/lib/gitlabhq/encode.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-04-11 23:03:56 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-04-11 23:03:56 +0300
commitb7558a2063a35778e226156ff7b5ab41d83be753 (patch)
treed14d065b729d933150c6770860f8d5bb7d86206a /lib/gitlabhq/encode.rb
parent52f6df7255ed40186bd1a0e92abaaf2b926f3817 (diff)
downloadgitlab-ce-b7558a2063a35778e226156ff7b5ab41d83be753.tar.gz
Removed encoding monkey patch
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