Permalink
Browse files

Usage of String#force_encoding instead of iconv. Fixes #89 and #81.

  • Loading branch information...
1 parent 14683e1 commit 0832e6dbf5edcd6eb867b4bcb576162b5c7fd054 Quentin Poirier committed Oct 1, 2012
Showing with 4 additions and 5 deletions.
  1. +2 −2 lib/output.rb
  2. +2 −2 plugins-disabled/Charset.rb
  3. +0 −1 whatweb
View
@@ -565,7 +565,7 @@ def utf8_elements!(obj)
#pp @charset
#pp obj.encoding
# read this - http://blog.grayproductions.net/articles/ruby_19s_string
- obj=obj.gsub!(/^.*$/,Iconv.iconv("UTF-8",@charset,obj).join) # this is a bad way to do this but it works
+ obj = obj.force_encoding('UTF-8')
# obj=obj.force_encoding("ASCII-8BIT")
#puts obj.encoding.name
@@ -677,7 +677,7 @@ def utf8_elements!(obj)
if obj.class == String
# obj=obj.upcase!
# obj=Iconv.iconv("UTF-8",@charset,obj).join
- obj=obj.gsub!(/^.*$/,Iconv.iconv("UTF-8",@charset,obj).join) # this is a bad way to do this but it works
+ obj = obj.force_encoding('UTF-8')
end
end
@@ -84,7 +84,7 @@ def passive
found=false
while trythis = trythese.pop
begin
- d=Iconv.iconv("UTF-8",trythis,body).join
+ d = body.force_encoding('UTF-8')
found=true
m << {:string=> trythis}
break
@@ -97,7 +97,7 @@ def passive
begin
cd = CharDet.detect(body)
encoding = cd['encoding'].upcase
- d=Iconv.iconv("UTF-8",encoding,body).join
+ d = body.force_encoding('UTF-8')
found=true
m << {:string=> encoding, :module=> "CharDet"}
rescue
View
@@ -42,7 +42,6 @@ require 'net/http'
require 'open-uri'
require 'cgi'
require 'thread'
-require 'iconv'
require 'tempfile'
require 'rbconfig' # detect environment, e.g. windows or linux
require 'resolv'

0 comments on commit 0832e6d

Please sign in to comment.