| 1 |
wakaba |
1.1 |
#!/usr/bin/perl |
| 2 |
|
|
package Whatpm::Charset::WebLatin1; |
| 3 |
|
|
use strict; |
| 4 |
|
|
our $VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
| 5 |
|
|
|
| 6 |
|
|
## NOTE: This module does not expect that its standalone uses. |
| 7 |
|
|
## See Message::Charset::Info for how it is used. |
| 8 |
|
|
|
| 9 |
|
|
require Encode::Encoding; |
| 10 |
|
|
push our @ISA, 'Encode::Encoding'; |
| 11 |
|
|
__PACKAGE__->Define (qw/web-thai/); |
| 12 |
|
|
|
| 13 |
|
|
sub encode ($$;$) { |
| 14 |
|
|
# $self, $str, $chk |
| 15 |
|
|
if ($_[2]) { |
| 16 |
|
|
if ($_[1] =~ s/^([\x00-\x7F\xA0\x{0E01}-\x{0E3A}\x{0E3F}-\x{0E5B}]+)//) { |
| 17 |
|
|
return Encode::encode ('iso-8859-11', $1); |
| 18 |
|
|
} else { |
| 19 |
|
|
return ''; |
| 20 |
|
|
} |
| 21 |
|
|
} else { |
| 22 |
|
|
my $r = $_[1]; |
| 23 |
|
|
$r =~ s/[^\x00-\x7F\xA0\x{0E01}-\x{0E3A}\x{0E3F}-\x{0E5B}]/?/g; |
| 24 |
|
|
return Encode::encode ('iso-8859-11', $r); |
| 25 |
|
|
} |
| 26 |
|
|
} # encode |
| 27 |
|
|
|
| 28 |
|
|
sub decode ($$;$) { |
| 29 |
|
|
# $self, $s, $chk |
| 30 |
|
|
if ($_[2]) { |
| 31 |
|
|
my $r = ''; |
| 32 |
|
|
while (1) { |
| 33 |
|
|
if ($_[1] =~ s/^([\x00-\x7F\xA0-\xDA\xDF-\xFB]+)//) { |
| 34 |
|
|
$r .= Encode::decode ('iso-8859-11', $1); |
| 35 |
|
|
} else { |
| 36 |
|
|
return $r; |
| 37 |
|
|
} |
| 38 |
|
|
} |
| 39 |
|
|
} else { |
| 40 |
|
|
return Encode::decode ('windows-874', $_[1]); |
| 41 |
|
|
} |
| 42 |
|
|
} # decode |
| 43 |
|
|
|
| 44 |
|
|
1; |
| 45 |
|
|
## $Date:$ |