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