From 62f5388a766644a7a51838a8cc2f9fe5f4e60e95 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Thu, 21 Jan 2010 14:35:28 +0100 Subject: quick and dirty fix for encoding problem --- html.rb | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'html.rb') diff --git a/html.rb b/html.rb index 6f714df..5dbb3e6 100644 --- a/html.rb +++ b/html.rb @@ -24,7 +24,11 @@ class HTML @header = {} @header["type"] = "text/html" # @header["type"] = "application/xhtml+xml" - @header["charset"] = "utf-8" + if $cgi.accept_charset =~ /utf-8/ || $cgi.accept_charset =~ /\*/ + @header["charset"] = "utf-8" + else + @header["charset"] = "iso-8859-1" + end @body = "" @css = [] @@ -72,6 +76,35 @@ HEAD @body += bodycontent.chomp + "\n" end def out(cgi) + #FIXME: quick and dirty fix for encoding problem + { + "ö" => "ö", + "ü" => "ü", + "ä" => "ä", + "Ö" => "Ö", + "Ü" => "Ü", + "Ä" => "Ä", + "ß" => "ß", + "–" => "–", + "„" => "„", + "“" => "“", + "”" => "”", + "✔" => "✔", + "✘" => "✘", + "◀" => "◀", + "▶" => "▶", + "✍" => "✍", + "✖" => "✖", + "•" => "•", + "▾" => "▾", + "▴" => "▴" + }.each{|from,to| + @body.gsub!(from,to) + } +# @body.gsub!(/./){|char| +# code = char[0] +# code > 127 ? "&##{code};" : char +# } cgi.out(@header){ <