enconverter 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/enconverter.gemspec +1 -1
- data/lib/enconverter/enconverter.rb +5 -5
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/enconverter.gemspec
CHANGED
@@ -19,7 +19,7 @@ module Rack
|
|
19
19
|
if convert && [nil, "text/html", "application/xhtml+xml"].include?(header[:content_type]) && response.respond_to?(:body)
|
20
20
|
type, charset = header['Content-Type'].split(/;\s*charset=/)
|
21
21
|
response.body = process_body(response.body)
|
22
|
-
header['Content-Type'] = "#{type}; charset=
|
22
|
+
header['Content-Type'] = "#{type}; charset=shift_jis"
|
23
23
|
end
|
24
24
|
|
25
25
|
[status, header, response]
|
@@ -28,13 +28,13 @@ module Rack
|
|
28
28
|
private
|
29
29
|
def process_body(body)
|
30
30
|
body_doc = Nokogiri::HTML(body)
|
31
|
-
body_doc.meta_encoding = '
|
31
|
+
body_doc.meta_encoding = 'shift_jis'
|
32
32
|
body_doc.search('meta[@http-equiv="Content-Type"]').map do |e|
|
33
|
-
e["content"] = e["content"].sub(/utf-?8/,'
|
33
|
+
e["content"] = e["content"].sub(/utf-?8/,'shift_jis')
|
34
34
|
end
|
35
35
|
|
36
36
|
body = body_doc.to_html
|
37
|
-
Iconv.conv('
|
37
|
+
Iconv.conv('shift_jis//IGNORE','utf-8', body).sub(/charset=utf-?8/,'charset=shift_jis')
|
38
38
|
end
|
39
39
|
|
40
40
|
def scrub(env)
|
@@ -57,7 +57,7 @@ module Rack
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def convert_japanese(str)
|
60
|
-
Iconv.conv('utf-8//IGNORE','
|
60
|
+
Iconv.conv('utf-8//IGNORE','shift_jis', str)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
metadata
CHANGED