Remove HanZi and 7bit-kr, from SADAHIRO Tomoyuki.
[p5sagit/p5-mst-13.2.git] / ext / Encode / lib / Encode / iso10646_1.pm
CommitLineData
df1df145 1package Encode::iso10646_1;
2use strict;
3our $VERSION = do {my @r=(q$Revision: 0.30 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r};
4use base 'Encode::Encoding';
5# Encoding is 16-bit network order Unicode (no surogates)
6# Used for X font encodings
7
8__PACKAGE__->Define(qw(UCS-2 iso-10646-1));
9
10sub decode
11{
12 my ($obj,$str,$chk) = @_;
13 my $uni = '';
14 while (length($str))
15 {
16 my $code = unpack('n',substr($str,0,2,'')) & 0xffff;
17 $uni .= chr($code);
18 }
19 $_[1] = $str if $chk;
20 utf8::upgrade($uni);
21 return $uni;
22}
23
24sub encode
25{
26 my ($obj,$uni,$chk) = @_;
27 my $str = '';
28 while (length($uni))
29 {
30 my $ch = substr($uni,0,1,'');
31 my $x = ord($ch);
32 unless ($x < 32768)
33 {
34 last if ($chk);
35 $x = 0;
36 }
37 $str .= pack('n',$x);
38 }
39 $_[1] = $uni if $chk;
40 return $str;
41}
421;
43__END__