41 |
decoder => sub { $_[1] }, |
decoder => sub { $_[1] }, |
42 |
|
|
43 |
mime_text => 1, |
mime_text => 1, |
44 |
|
cte_7bit_preferred => 'quoted-printable', |
45 |
}; |
}; |
46 |
|
|
47 |
$CHARSET{'iso-2022-int-1'} = { |
$CHARSET{'iso-2022-int-1'} = { |
59 |
encoder => sub { $_[1] }, |
encoder => sub { $_[1] }, |
60 |
decoder => sub { $_[1] }, |
decoder => sub { $_[1] }, |
61 |
|
|
62 |
|
mime_text => 1, |
63 |
|
cte_7bit_preferred => 'base64', |
64 |
|
}; |
65 |
|
|
66 |
|
$CHARSET{'x-unknown'} = { |
67 |
|
preferred_name => 'x-unknown', |
68 |
|
|
69 |
|
encoder => sub { $_[1] }, |
70 |
|
decoder => sub { $_[1] }, |
71 |
|
|
72 |
|
mime_text => 0, |
73 |
|
cte_7bit_preferred => 'base64', |
74 |
|
}; |
75 |
|
|
76 |
|
$CHARSET{'*undef'} = { |
77 |
|
preferred_name => '', |
78 |
|
|
79 |
|
#encoder => sub { $_[1] }, |
80 |
|
#decoder => sub { $_[1] }, |
81 |
|
|
82 |
mime_text => 0, |
mime_text => 0, |
83 |
cte_7bit_preferred => 'base64', |
cte_7bit_preferred => 'base64', |
84 |
}; |
}; |
|
$CHARSET{'x-unknown'} = $CHARSET{'unknown-8bit'}; |
|
85 |
|
|
86 |
} # /builtin_charset |
} # /builtin_charset |
87 |
|
|
153 |
|
|
154 |
sub encode ($$) { |
sub encode ($$) { |
155 |
my ($charset, $s) = (lc shift, shift); |
my ($charset, $s) = (lc shift, shift); |
156 |
if (ref $CHARSET{$charset}->{encoder}) { |
my $c = ref $CHARSET{$charset}->{encoder}? $charset: '*undef'; |
157 |
return (&{$CHARSET{$charset}->{encoder}} ($charset, $s), success => 1); |
if (ref $CHARSET{$c}->{encoder}) { |
158 |
|
my ($t, %r) = &{$CHARSET{$c}->{encoder}} ($charset, $s); |
159 |
|
unless (defined $r{success}) { |
160 |
|
$r{success} = 1; |
161 |
|
} |
162 |
|
return ($t, %r); |
163 |
} |
} |
164 |
($s, success => 0); |
($s, success => 0); |
165 |
} |
} |
166 |
|
|
167 |
sub decode ($$) { |
sub decode ($$) { |
168 |
my ($charset, $s) = (lc shift, shift); |
my ($charset, $s) = (lc shift, shift); |
169 |
if (ref $CHARSET{$charset}->{decoder}) { |
my $c = ref $CHARSET{$charset}->{decoder}? $charset: '*undef'; |
170 |
return (&{$CHARSET{$charset}->{decoder}} ($charset, $s), 1); |
if (ref $CHARSET{$c}->{decoder}) { |
171 |
|
my ($t, %r) = &{$CHARSET{$c}->{decoder}} ($charset, $s); |
172 |
|
unless (defined $r{success}) { |
173 |
|
$r{success} = 1; |
174 |
|
} |
175 |
|
return ($t, %r); |
176 |
} |
} |
177 |
($s, 0); |
($s, success => 0); |
178 |
} |
} |
179 |
|
|
180 |
sub name_normalize ($) { |
sub name_normalize ($) { |
188 |
return &{$CHARSET{$charset}->{name_minimumizer}} ($charset, $s); |
return &{$CHARSET{$charset}->{name_minimumizer}} ($charset, $s); |
189 |
} elsif (ref $_MINIMUMIZER{$charset}) { |
} elsif (ref $_MINIMUMIZER{$charset}) { |
190 |
return &{$_MINIMUMIZER{$charset}} ($charset, $s); |
return &{$_MINIMUMIZER{$charset}} ($charset, $s); |
191 |
|
} elsif (ref $CHARSET{'*undef'}->{name_minimumizer} eq 'CODE') { |
192 |
|
return &{$CHARSET{'*undef'}->{name_minimumizer}} ($charset, $s); |
193 |
} |
} |
194 |
(charset => $charset); |
(charset => $charset); |
195 |
} |
} |
466 |
} |
} |
467 |
} |
} |
468 |
|
|
469 |
|
sub _utf8_on ($) { |
470 |
|
Encode::_utf8_on ($_[0]) if $Encode::VERSION; |
471 |
|
} |
472 |
|
sub _utf8_off ($) { |
473 |
|
Encode::_utf8_off ($_[0]) if $Encode::VERSION; |
474 |
|
} |
475 |
|
|
476 |
=head1 LICENSE |
=head1 LICENSE |
477 |
|
|
478 |
Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>. |
Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>. |