lib/ refactoring. Module Gitlabhq renamed to Gitlab
This commit is contained in:
parent
8ceb94081a
commit
3272620f72
20 changed files with 87 additions and 85 deletions
20
lib/gitlab/encode.rb
Normal file
20
lib/gitlab/encode.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module Gitlab
|
||||
module Encode
|
||||
extend self
|
||||
|
||||
def utf8 message
|
||||
return nil unless message
|
||||
|
||||
hash = CharlockHolmes::EncodingDetector.detect(message) rescue {}
|
||||
if hash[:encoding]
|
||||
CharlockHolmes::Converter.convert(message, hash[:encoding], 'UTF-8')
|
||||
else
|
||||
message
|
||||
end.force_encoding("utf-8")
|
||||
# Prevent app from crash cause of
|
||||
# encoding errors
|
||||
rescue
|
||||
""
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue