/[suikacvs]/test/oldencodeutils/lib/Encode/HZ.pm
Suika

Contents of /test/oldencodeutils/lib/Encode/HZ.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Thu Dec 12 08:17:16 2002 UTC (23 years, 7 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +11 -9 lines
Error occurred while calculating annotation data.
]

1 package Encode::HZ;
2 use strict;
3
4 use vars qw($VERSION);
5 $VERSION = do {my @r =(q$Revision: 1.4 $ =~ /\d+/g);sprintf "%d."."%02d" x $#r, @r};
6 use base qw(Encode::Encoding);
7 __PACKAGE__->Define(qw/hz chinese-hz hz-gb-2312 hz-gb2312 cp52936/);
8
9 sub needs_lines { 1 }
10
11 sub perlio_ok {
12 return 0; # for the time being
13 }
14
15 sub decode
16 {
17 my ($obj,$str,$chk) = @_;
18 my $gb = Encode::find_encoding($obj->__hz_encoding_name);
19
20 $str =~ s{~ # starting tilde
21 (?:
22 (~) # another tilde - escaped (set $1)
23 | # or
24 \x0D?\x0A # \n - output nothing
25 | # or
26 \{ # opening brace of GB data
27 ( # set $2 to any number of...
28 (?:[\x21-\x7D][\x21-\x7E])*
29 )
30 ~\} # closing brace of GB data
31 |
32 \{
33 ((?:[\x21-\x7D][\x21-\x7E])+[\x0D\x0A])
34 # | # XXX: invalid escape - maybe die on $chk?
35 )
36 }{