line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
package HTML::HTML5::Parser::Charset::WebLatin1; |
3
|
|
|
|
|
|
|
## skip Test::Tabs |
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
420
|
|
6
|
|
|
|
|
|
|
our $VERSION='0.991'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
## NOTE: This module does not expect that its standalone uses. |
9
|
|
|
|
|
|
|
## See Message::Charset::Info for how it is used. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Encode::Encoding; |
12
|
|
|
|
|
|
|
push our @ISA, 'Encode::Encoding'; |
13
|
|
|
|
|
|
|
__PACKAGE__->Define (qw/web-latin1/); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub encode ($$;$) { |
16
|
|
|
|
|
|
|
# $self, $str, $chk |
17
|
0
|
0
|
|
0
|
1
|
0
|
if ($_[2]) { |
18
|
0
|
0
|
|
|
|
0
|
if ($_[1] =~ s/^([\x00-\x7F\xA0-\xFF]+)//) { |
19
|
0
|
|
|
|
|
0
|
return Encode::encode ('iso-8859-1', $1); |
20
|
|
|
|
|
|
|
} else { |
21
|
0
|
|
|
|
|
0
|
return ''; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} else { |
24
|
0
|
|
|
|
|
0
|
my $r = $_[1]; |
25
|
0
|
|
|
|
|
0
|
$r =~ s/[^\x00-\x7F\xA0-\xFF]/?/g; |
26
|
0
|
|
|
|
|
0
|
return Encode::encode ('iso-8859-1', $r); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} # encode |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub decode ($$;$) { |
31
|
|
|
|
|
|
|
# $self, $s, $chk |
32
|
0
|
0
|
|
0
|
1
|
0
|
if ($_[2]) { |
33
|
0
|
|
|
|
|
0
|
my $r = ''; |
34
|
0
|
|
|
|
|
0
|
while (1) { |
35
|
0
|
0
|
|
|
|
0
|
if ($_[1] =~ s/^([\x00-\x7F\xA0-\xFF]+)//) { |
36
|
0
|
|
|
|
|
0
|
$r .= $1; |
37
|
|
|
|
|
|
|
#} elsif ($_[1] =~ s/^([\x80\x82-\x8C\x8E\x91-\x9C\x9E\x9F])//) { |
38
|
|
|
|
|
|
|
# my $v = $1; |
39
|
|
|
|
|
|
|
# $v =~ tr/\x80-\x9F/\x{20AC}\x{FFFD}\x{201A}\x{0192}\x{201E}\x{2026}\x{2020}\x{2021}\x{02C6}\x{2030}\x{0160}\x{2039}\x{0152}\x{FFFD}\x{017D}\x{FFFD}\x{FFFD}\x{2018}\x{2019}\x{201C}\x{201D}\x{2022}\x{2013}\x{2014}\x{02DC}\x{2122}\x{0161}\x{203A}\x{0153}\x{FFFD}\x{017E}\x{0178}/; |
40
|
|
|
|
|
|
|
# $r .= $v; |
41
|
|
|
|
|
|
|
} else { |
42
|
0
|
|
|
|
|
0
|
return $r; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} else { |
46
|
0
|
|
|
|
|
0
|
my $r = $_[1]; |
47
|
0
|
|
|
|
|
0
|
$r =~ tr/\x80-\x9F/\x{20AC}\x{FFFD}\x{201A}\x{0192}\x{201E}\x{2026}\x{2020}\x{2021}\x{02C6}\x{2030}\x{0160}\x{2039}\x{0152}\x{FFFD}\x{017D}\x{FFFD}\x{FFFD}\x{2018}\x{2019}\x{201C}\x{201D}\x{2022}\x{2013}\x{2014}\x{02DC}\x{2122}\x{0161}\x{203A}\x{0153}\x{FFFD}\x{017E}\x{0178}/; |
48
|
0
|
|
|
|
|
0
|
return $r; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} # decode |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package HTML::HTML5::Parser::Charset::USASCII; |
53
|
|
|
|
|
|
|
push our @ISA, 'Encode::Encoding'; |
54
|
|
|
|
|
|
|
__PACKAGE__->Define (qw/web-latin1-us-ascii/); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub encode ($$;$) { |
57
|
|
|
|
|
|
|
# $self, $str, $chk |
58
|
0
|
0
|
|
0
|
|
0
|
if ($_[2]) { |
59
|
0
|
0
|
|
|
|
0
|
if ($_[1] =~ s/^([\x00-\x7F]+)//) { |
60
|
0
|
|
|
|
|
0
|
return Encode::encode ('iso-8859-1', $1); |
61
|
|
|
|
|
|
|
} else { |
62
|
0
|
|
|
|
|
0
|
return ''; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} else { |
65
|
0
|
|
|
|
|
0
|
my $r = $_[1]; |
66
|
0
|
|
|
|
|
0
|
$r =~ s/[^\x00-\x7F]/?/g; |
67
|
0
|
|
|
|
|
0
|
return Encode::encode ('iso-8859-1', $r); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} # encode |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub decode ($$;$) { |
72
|
|
|
|
|
|
|
# $self, $s, $chk |
73
|
6
|
50
|
|
6
|
|
113
|
if ($_[2]) { |
74
|
6
|
|
|
|
|
10
|
my $r = ''; |
75
|
6
|
|
|
|
|
11
|
while (1) { |
76
|
8
|
100
|
|
|
|
58
|
if ($_[1] =~ s/^([\x00-\x7F]+)//) { |
77
|
2
|
|
|
|
|
10
|
$r .= $1; |
78
|
|
|
|
|
|
|
#} elsif ($_[1] =~ s/^([\x80\x82-\x8C\x8E\x91-\x9C\x9E\x9F-\xFF])//) { |
79
|
|
|
|
|
|
|
# my $v = $1; |
80
|
|
|
|
|
|
|
# $v =~ tr/\x80-\xFF/\x{20AC}\x{FFFD}\x{201A}\x{0192}\x{201E}\x{2026}\x{2020}\x{2021}\x{02C6}\x{2030}\x{0160}\x{2039}\x{0152}\x{FFFD}\x{017D}\x{FFFD}\x{FFFD}\x{2018}\x{2019}\x{201C}\x{201D}\x{2022}\x{2013}\x{2014}\x{02DC}\x{2122}\x{0161}\x{203A}\x{0153}\x{FFFD}\x{017E}\x{0178}\xA0-\xFF/; |
81
|
|
|
|
|
|
|
# $r .= $v; |
82
|
|
|
|
|
|
|
} else { |
83
|
6
|
|
|
|
|
38
|
return $r; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} else { |
87
|
0
|
|
|
|
|
|
my $r = $_[1]; |
88
|
0
|
|
|
|
|
|
$r =~ tr/\x80-\xFF/\x{20AC}\x{FFFD}\x{201A}\x{0192}\x{201E}\x{2026}\x{2020}\x{2021}\x{02C6}\x{2030}\x{0160}\x{2039}\x{0152}\x{FFFD}\x{017D}\x{FFFD}\x{FFFD}\x{2018}\x{2019}\x{201C}\x{201D}\x{2022}\x{2013}\x{2014}\x{02DC}\x{2122}\x{0161}\x{203A}\x{0153}\x{FFFD}\x{017E}\x{0178}\xA0-\xFF/; |
89
|
0
|
|
|
|
|
|
return $r; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} # decode |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
package HTML::HTML5::Parser::Charset::WebLatin5; |
94
|
|
|
|
|
|
|
push our @ISA, 'Encode::Encoding'; |
95
|
|
|
|
|
|
|
__PACKAGE__->Define (qw/web-latin5/); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub encode ($$;$) { |
98
|
|
|
|
|
|
|
# $self, $str, $chk |
99
|
0
|
0
|
|
0
|
|
|
if ($_[2]) { |
100
|
0
|
0
|
|
|
|
|
if ($_[1] =~ s/^([\x00-\x7F]+)//) { |
101
|
0
|
|
|
|
|
|
return Encode::encode ('iso-8859-9', $1); |
102
|
|
|
|
|
|
|
} else { |
103
|
0
|
|
|
|
|
|
return ''; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} else { |
106
|
0
|
|
|
|
|
|
my $r = $_[1]; |
107
|
0
|
|
|
|
|
|
$r =~ s/[^\x00-\x7F]/?/g; |
108
|
0
|
|
|
|
|
|
return Encode::encode ('iso-8859-9', $r); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} # encode |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub decode ($$;$) { |
113
|
|
|
|
|
|
|
# $self, $s, $chk |
114
|
0
|
0
|
|
0
|
|
|
if ($_[2]) { |
115
|
0
|
|
|
|
|
|
my $r = ''; |
116
|
0
|
|
|
|
|
|
while (1) { |
117
|
0
|
0
|
|
|
|
|
if ($_[1] =~ s/^([\x00-\x7F\xA0-\xFF]+)//) { |
118
|
0
|
|
|
|
|
|
$r .= Encode::decode ('windows-1254', $1); |
119
|
|
|
|
|
|
|
#} elsif ($_[1] =~ s/^([\x80\x82-\x8C\x91-\x9C\x9F])//) { |
120
|
|
|
|
|
|
|
# my $v = $1; |
121
|
|
|
|
|
|
|
# $v =~ tr/\x80-\x9F/\x{20AC}\x{FFFD}\x{201A}\x{0192}\x{201E}\x{2026}\x{2020}\x{2021}\x{02C6}\x{2030}\x{0160}\x{2039}\x{0152}\x{FFFD}\x{FFFD}\x{FFFD}\x{FFFD}\x{2018}\x{2019}\x{201C}\x{201D}\x{2022}\x{2013}\x{2014}\x{02DC}\x{2122}\x{0161}\x{203A}\x{0153}\x{FFFD}\x{FFFD}\x{0178}/; |
122
|
|
|
|
|
|
|
# $r .= $v; |
123
|
|
|
|
|
|
|
} else { |
124
|
0
|
|
|
|
|
|
return $r; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} else { |
128
|
0
|
|
|
|
|
|
my $r = Encode::decode ('windows-1254', $_[1]); |
129
|
0
|
|
|
|
|
|
return $r; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} # decode |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
## $Date: 2008/09/10 10:27:09 $ |