52 |
|
|
53 |
$| = 0; |
$| = 0; |
54 |
my $input = get_input_document ($http, $dom); |
my $input = get_input_document ($http, $dom); |
|
my $inner_html_element = $http->get_parameter ('e'); |
|
55 |
my $char_length = 0; |
my $char_length = 0; |
56 |
my %time; |
my %time; |
57 |
|
|
252 |
|
|
253 |
my $doc = $dom->create_document; |
my $doc = $dom->create_document; |
254 |
my $el; |
my $el; |
255 |
|
my $inner_html_element = $http->get_parameter ('e'); |
256 |
if (defined $inner_html_element and length $inner_html_element) { |
if (defined $inner_html_element and length $inner_html_element) { |
257 |
$input->{charset} ||= 'ISO-8859-1'; ## TODO: for now. |
$input->{charset} ||= 'windows-1252'; ## TODO: for now. |
258 |
my $time1 = time; |
my $time1 = time; |
259 |
my $t = Encode::decode ($input->{charset}, $input->{s}); |
my $t = Encode::decode ($input->{charset}, $input->{s}); |
260 |
$time{decode} = time - $time1; |
$time{decode} = time - $time1; |
270 |
($input->{charset}, $input->{s} => $doc, $onerror); |
($input->{charset}, $input->{s} => $doc, $onerror); |
271 |
$time{parse_html} = time - $time1; |
$time{parse_html} = time - $time1; |
272 |
} |
} |
273 |
|
$doc->manakai_charset ($input->{official_charset}) |
274 |
|
if defined $input->{official_charset}; |
275 |
|
|
276 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
277 |
|
|
312 |
my $doc = Message::DOM::XMLParserTemp->parse_byte_stream |
my $doc = Message::DOM::XMLParserTemp->parse_byte_stream |
313 |
($fh => $dom, $onerror, charset => $input->{charset}); |
($fh => $dom, $onerror, charset => $input->{charset}); |
314 |
$time{parse_xml} = time - $time1; |
$time{parse_xml} = time - $time1; |
315 |
|
$doc->manakai_charset ($input->{official_charset}) |
316 |
|
if defined $input->{official_charset}; |
317 |
|
|
318 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
319 |
|
|
899 |
|
|
900 |
sub load_text_catalog ($) { |
sub load_text_catalog ($) { |
901 |
my $lang = shift; # MUST be a canonical lang name |
my $lang = shift; # MUST be a canonical lang name |
902 |
open my $file, '<', "cc-msg.$lang.txt" or die "$0: cc-msg.$lang.txt: $!"; |
open my $file, '<:utf8', "cc-msg.$lang.txt" |
903 |
|
or die "$0: cc-msg.$lang.txt: $!"; |
904 |
while (<$file>) { |
while (<$file>) { |
905 |
if (s/^([^;]+);([^;]*);//) { |
if (s/^([^;]+);([^;]*);//) { |
906 |
my ($type, $cls, $msg) = ($1, $2, $_); |
my ($type, $cls, $msg) = ($1, $2, $_); |
1011 |
if (defined $ct and $ct =~ /;\s*charset\s*=\s*"?([^\s;"]+)"?/i) { |
if (defined $ct and $ct =~ /;\s*charset\s*=\s*"?([^\s;"]+)"?/i) { |
1012 |
$r->{charset} = lc $1; |
$r->{charset} = lc $1; |
1013 |
$r->{charset} =~ tr/\\//d; |
$r->{charset} =~ tr/\\//d; |
1014 |
|
$r->{official_charset} = $r->{charset}; |
1015 |
} |
} |
1016 |
|
|
1017 |
my $input_charset = $http->get_parameter ('charset'); |
my $input_charset = $http->get_parameter ('charset'); |
1055 |
$r->{charset} = ''.$http->get_parameter ('_charset_'); |
$r->{charset} = ''.$http->get_parameter ('_charset_'); |
1056 |
$r->{charset} =~ s/\s+//g; |
$r->{charset} =~ s/\s+//g; |
1057 |
$r->{charset} = 'utf-8' if $r->{charset} eq ''; |
$r->{charset} = 'utf-8' if $r->{charset} eq ''; |
1058 |
|
$r->{official_charset} = $r->{charset}; |
1059 |
$r->{header_field} = []; |
$r->{header_field} = []; |
1060 |
|
|
1061 |
require Whatpm::ContentType; |
require Whatpm::ContentType; |
1083 |
if ($r->{media_type} eq 'text/xml') { |
if ($r->{media_type} eq 'text/xml') { |
1084 |
unless (defined $r->{charset}) { |
unless (defined $r->{charset}) { |
1085 |
$r->{charset} = 'us-ascii'; |
$r->{charset} = 'us-ascii'; |
1086 |
|
$r->{official_charset} = $r->{charset}; |
1087 |
} elsif ($r->{charset_overridden} and $r->{charset} eq 'us-ascii') { |
} elsif ($r->{charset_overridden} and $r->{charset} eq 'us-ascii') { |
1088 |
$r->{charset_overridden} = 0; |
$r->{charset_overridden} = 0; |
1089 |
} |
} |