--- test/html-webhacc/cc.cgi 2008/05/06 08:47:09 1.50 +++ test/html-webhacc/cc.cgi 2008/05/18 03:47:56 1.51 @@ -677,11 +677,28 @@ my $input = shift; my $s; unless ($input->{is_char_string}) { - require Encode; - my $enc = Encode::find_encoding ($_[1]); ## TODO: charset name -> Perl name - return unless $enc; + open my $byte_stream, '<', $_[0]; + require Message::Charset::Info; + my $charset = Message::Charset::Info->get_by_iana_name ($_[1]); + my ($char_stream, $e_status) = $charset->get_decode_handle + ($byte_stream, allow_error_reporting => 1, allow_fallback => 1); + return unless $char_stream; + + $char_stream->onerror (sub { + my (undef, $type, %opt) = @_; + if ($opt{octets}) { + ${$opt{octets}} = "\x{FFFD}"; + } + }); - $s = \($enc->decode (${$_[0]})); + my $t = ''; + while (1) { + my $c = $char_stream->getc; + last unless defined $c; + $t .= $c; + } + $s = \$t; + ## TODO: Output for each line, don't concat all of lines. } else { $s = $_[0]; } @@ -1182,24 +1199,25 @@ print STDOUT qq[
Important: This conformance checking service @@ -1623,4 +1641,4 @@ =cut -## $Date: 2008/05/06 08:47:09 $ +## $Date: 2008/05/18 03:47:56 $