/[suikacvs]/markup/html/whatpm/Whatpm/Charset/DecodeHandle.pm
Suika

Diff of /markup/html/whatpm/Whatpm/Charset/DecodeHandle.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by wakaba, Sat May 17 12:29:24 2008 UTC revision 1.5 by wakaba, Sun May 18 04:15:52 2008 UTC
# Line 574  sub getc ($) { Line 574  sub getc ($) {
574    
575    my $r;    my $r;
576    unless ($error) {    unless ($error) {
577        if (not $self->{bom_checked}) {
578          if (defined $self->{bom_pattern}) {
579            if ($self->{byte_buffer} =~ s/^$self->{bom_pattern}//) {
580              $self->{has_bom} = 1;
581            }
582          }
583          $self->{bom_checked} = 1;
584        }
585    
586      my $string = Encode::decode ($self->{perl_encoding_name},      my $string = Encode::decode ($self->{perl_encoding_name},
587                                   $self->{byte_buffer},                                   $self->{byte_buffer},
588                                   Encode::FB_QUIET ());                                   Encode::FB_QUIET ());
# Line 854  sub getc ($) { Line 863  sub getc ($) {
863    if ($error) {    if ($error) {
864      $r = substr $self->{byte_buffer}, 0, 1, '';      $r = substr $self->{byte_buffer}, 0, 1, '';
865      my $etype = 'illegal-octets-error';      my $etype = 'illegal-octets-error';
866      if ($r =~ /^[\x81-\x9F\xE0-\xEF]/) {      if ($r =~ /^[\x81-\x9F\xE0-\xFC]/) {
867        if ($self->{byte_buffer} =~ s/(.)//s) {        if ($self->{byte_buffer} =~ s/(.)//s) {
868          $r .= $1;                     # not limited to \x40-\xFC - \x7F          $r .= $1;                     # not limited to \x40-\xFC - \x7F
869          $etype = 'unassigned-code-point-error';          $etype = 'unassigned-code-point-error';
870        }        }
871      } elsif ($r =~ /^[\x80\xA0\xF0-\xFF]/) {        ## NOTE: Range [\xF0-\xFC] is unassigned and may be used as a single-byte
872          ## character or as the first-byte of a double-byte character according
873          ## to JIS X 0208:1997 Appendix 1.  However, the current practice is
874          ## use the range as the first-byte of double-byte characters.
875        } elsif ($r =~ /^[\x80\xA0\xFD-\xFF]/) {
876        $etype = 'unassigned-code-point-error';        $etype = 'unassigned-code-point-error';
877      }      }
878      $self->{onerror}->($self, $etype, octets => \$r);      $self->{onerror}->($self, $etype, octets => \$r);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.5

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24