summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaito <saitowu@gmail.com>2011-12-30 18:30:57 +0800
committerSaito <saitowu@gmail.com>2011-12-30 18:30:57 +0800
commit7279e8c1774f3116dd74ca462447189730f9eff8 (patch)
tree438c5671951a2a01e1484c3a3bb099a1d26eb162
parent5719f02f34339237a2b1faeda30976a404358910 (diff)
downloadgitlab-ce-7279e8c1774f3116dd74ca462447189730f9eff8.tar.gz
Revert "merge charlock_holmes to master"
This reverts commit a25a85b9396cbc07bf2bfcd12d3c0a6685df66d6.
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock4
-rw-r--r--lib/utils.rb14
3 files changed, 11 insertions, 9 deletions
diff --git a/Gemfile b/Gemfile
index e240fa65b91..3c7b1a4f91f 100644
--- a/Gemfile
+++ b/Gemfile
@@ -22,9 +22,9 @@ gem "acts_as_list"
gem "rdiscount"
gem "acts-as-taggable-on", "~> 2.1.0"
gem "drapper"
+gem "rchardet19", "~> 1.3.5"
gem "resque"
gem "httparty"
-gem "charlock_holmes"
group :assets do
gem "sass-rails", "~> 3.1.0"
diff --git a/Gemfile.lock b/Gemfile.lock
index 86a69981004..09fecb8878e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -77,7 +77,6 @@ GEM
xpath (~> 0.1.4)
carrierwave (0.5.8)
activesupport (~> 3.0)
- charlock_holmes (0.6.8)
childprocess (0.2.2)
ffi (~> 1.0.6)
coffee-rails (3.1.1)
@@ -173,6 +172,7 @@ GEM
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
+ rchardet19 (1.3.5)
rdiscount (1.6.8)
rdoc (3.11)
json (~> 1.4)
@@ -285,7 +285,6 @@ DEPENDENCIES
awesome_print
capybara
carrierwave
- charlock_holmes
coffee-rails (~> 3.1.0)
database_cleaner
devise (= 1.5.0)
@@ -303,6 +302,7 @@ DEPENDENCIES
pygments.rb (= 0.2.3)
rails (= 3.1.1)
rails-footnotes (~> 3.7.5)
+ rchardet19 (~> 1.3.5)
rdiscount
resque
rspec-rails
diff --git a/lib/utils.rb b/lib/utils.rb
index 8e5d4694cac..2de14761444 100644
--- a/lib/utils.rb
+++ b/lib/utils.rb
@@ -17,13 +17,15 @@ module Utils
end
module CharEncode
- def encode(content)
- content ||= ''
- detection = CharlockHolmes::EncodingDetector.detect(content)
- if hash = detection
- content = CharlockHolmes::Converter.convert(content, hash[:encoding], 'UTF-8') if hash[:encoding]
+ def encode(string)
+ return '' unless string
+ cd = CharDet.detect(string)
+ if cd.confidence > 0.6
+ string.force_encoding(cd.encoding)
end
- content
+ string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)
+ rescue
+ "Invalid Encoding"
end
end