/[suikacvs]/markup/html/whatpm/Whatpm/Charset/WebThai.pm
Suika

Contents of /markup/html/whatpm/Whatpm/Charset/WebThai.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sun May 18 06:07:22 2008 UTC (17 years, 1 month ago) by wakaba
Branch: MAIN
++ whatpm/Whatpm/Charset/ChangeLog	18 May 2008 06:07:15 -0000
	* WebThai.pm, WebLatin1.pm: New modules.

	* DecodeHandle.pm: Support for fallback character mappings,
	used for WebLatin1 and WebThai encodings.

2008-05-18  Wakaba  <wakaba@suika.fam.cx>

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:$

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24