Class: Kudzu::Agent::Util::CharsetDetector
- Inherits:
-
Object
- Object
- Kudzu::Agent::Util::CharsetDetector
- Defined in:
- lib/kudzu/agent/util/charset_detector.rb
Constant Summary collapse
- CORRECTION =
{ 'utf_8' => 'utf-8', 'shift-jis' => 'shift_jis', 'x-sjis' => 'shift_jis', 'euc_jp' => 'euc-jp' }
Class Method Summary collapse
Class Method Details
.detect(response) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kudzu/agent/util/charset_detector.rb', line 13 def detect(response) if response.html? from_html(response.body) || from_text(response.body) elsif response.xml? from_xml(response.body) || from_text(response.body) elsif response.text? from_text(response.body) end rescue => e Kudzu.log :warn, "failed to detect charset: #{response.url}", error: e nil end |