1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#!/usr/bin/perl
package HTML::HTML5::Parser::Charset::WebThai;
## skip Test::Tabs
use strict;
use warnings;
our $VERSION='0.992';
## NOTE: This module does not expect that its standalone uses.
## See Message::Charset::Info for how it is used.
require Encode::Encoding;
push our @ISA, 'Encode::Encoding';
__PACKAGE__->Define (qw/web-thai/);
sub encode ($$;$) {
# $self, $str, $chk
if ($_[2]) {
if ($_[1] =~ s/^([\x00-\x7F\xA0\x{0E01}-\x{0E3A}\x{0E3F}-\x{0E5B}]+)//) {
return Encode::encode ('iso-8859-11', $1);
} else {
return '';
}
} else {
my $r = $_[1];
$r =~ s/[^\x00-\x7F\xA0\x{0E01}-\x{0E3A}\x{0E3F}-\x{0E5B}]/?/g;
return Encode::encode ('iso-8859-11', $r);
}
} # encode
sub decode ($$;$) {
# $self, $s, $chk
if ($_[2]) {
my $r = '';
while (1) {
if ($_[1] =~ s/^([\x00-\x7F\xA0-\xDA\xDF-\xFB]+)//) {
$r .= Encode::decode ('iso-8859-11', $1);
} else {
return $r;
}
}
} else {
return Encode::decode ('windows-874', $_[1]);
}
} # decode
package HTML::HTML5::Parser::Charset::WebThai::WebTIS620;
push our @ISA, 'Encode::Encoding';
__PACKAGE__->Define (qw/web-tis-620/);
sub encode ($$;$) {
# $self, $str, $chk
if ($_[2]) {
if ($_[1] =~ s/^([\x00-\x7F\x{0E01}-\x{0E3A}\x{0E3F}-\x{0E5B}]+)//) {
return Encode::encode ('tis-620', $1);
} else {
return '';
}
} else {
my $r = $_[1];
$r =~ s/[^\x00-\x7F\x{0E01}-\x{0E3A}\x{0E3F}-\x{0E5B}]/?/g;
return Encode::encode ('tis-620', $r);
}
} # encode
sub decode ($$;$) {
# $self, $s, $chk
if ($_[2]) {
my $r = '';
while (1) {
if ($_[1] =~ s/^([\x00-\x7F\xA1-\xDA\xDF-\xFB]+)//) {
$r .= Encode::decode ('tis-620', $1);
} else {
return $r;
}
}
} else {
return Encode::decode ('windows-874', $_[1]);
}
} # decode
1;
## $Date: 2008/09/10 10:27:09 $
|