92 |
my $s; |
my $s; |
93 |
|
|
94 |
if (defined $charset) { |
if (defined $charset) { |
95 |
require Encode; |
require Encode; ## TODO: decode(utf8) don't delete BOM |
96 |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
97 |
$self->{input_encoding} = lc $charset; ## TODO: normalize name ## TODO: set $doc->input_encoding |
$self->{input_encoding} = lc $charset; ## TODO: normalize name |
98 |
$self->{confident} = 1; |
$self->{confident} = 1; |
99 |
} else { |
} else { |
100 |
$s = ref $_[0] ? $_[0] : \($_[0]); |
$charset = 'windows-1252'; ## TODO: for now. |
101 |
|
$s = \ (Encode::decode ($charset, $$bytes_s)); |
102 |
|
$self->{input_encoding} = $charset; |
103 |
$self->{confident} = 0; |
$self->{confident} = 0; |
104 |
} |
} |
105 |
|
|
123 |
return; |
return; |
124 |
} |
} |
125 |
|
|
126 |
!!!parse-error (type => 'charset label detected', level => 'w'); |
!!!parse-error (type => 'charset label detected:'.$self->{input_encoding}. |
127 |
|
':'.$charset, level => 'w'); |
128 |
|
|
129 |
## Step 3 |
## Step 3 |
130 |
# if (can) { |
# if (can) { |
144 |
} catch Whatpm::HTML::RestartParser with { |
} catch Whatpm::HTML::RestartParser with { |
145 |
my $charset = shift->{charset}; |
my $charset = shift->{charset}; |
146 |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
147 |
$self->{input_encoding} = $charset; ## TODO: $doc->input_encoding; |
$self->{input_encoding} = $charset; ## TODO: normalize |
148 |
$self->{confident} = 1; |
$self->{confident} = 1; |
149 |
$return = $self->parse_char_string ($s, @args); |
$return = $self->parse_char_string ($s, @args); |
150 |
}; |
}; |
162 |
## NOTE: |set_inner_html| copies most of this method's code |
## NOTE: |set_inner_html| copies most of this method's code |
163 |
|
|
164 |
$self->{confident} = 1 unless exists $self->{confident}; |
$self->{confident} = 1 unless exists $self->{confident}; |
165 |
|
$self->{document}->input_encoding ($self->{input_encoding}) |
166 |
|
if defined $self->{input_encoding}; |
167 |
|
|
168 |
my $i = 0; |
my $i = 0; |
169 |
my $line = 1; |
my $line = 1; |