/[suikacvs]/messaging/manakai/lib/Message/MIME/Charset.pm
Suika

Diff of /messaging/manakai/lib/Message/MIME/Charset.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by wakaba, Sat Jun 1 05:37:18 2002 UTC revision 1.6 by wakaba, Sun Jun 9 11:13:14 2002 UTC
# Line 42  $CHARSET{'iso-2022-int-1'} = { Line 42  $CHARSET{'iso-2022-int-1'} = {
42                    
43          encoder => sub { $_[1] },          encoder => sub { $_[1] },
44          decoder => sub { $_[1] },          decoder => sub { $_[1] },
45            name_minimumizer        => sub {
46              shift; my $s = shift;
47              return (charset => 'us-ascii') unless $s =~ /[\x1B\x0E\x0F]/;
48              return (charset => 'iso-2022-jp') unless $s =~ /\x1B[^\x24\x28]|\x1B\x24[^\x40B]|\x1B\x28[^BJ]|\x0E|\x0F/;
49              return (charset => 'iso-2022-jp-1') unless $s =~ /\x1B[^\x24\x28]|\x1B\x24[^\x40B\x28]|\x1B\x28[^BJ]|\x1B\x24\x28[^D]|\x0E|\x0F/;
50              return (charset => 'iso-2022-jp-3-plane1') unless $s =~ /\x1B[^\x24\x28]|\x1B\x24[^B\x28]|\x1B\x28[^B]|\x1B\x24\x28[^O]|\x0E|\x0F/;
51              return (charset => 'iso-2022-jp-3') unless $s =~ /\x1B[^\x24\x28]|\x1B\x24[^B\x28]|\x1B\x28[^B]|\x1B\x24\x28[^OP]|\x0E|\x0F/;
52              return (charset => 'iso-2022-kr') unless $s =~ /\x1B[^\x24]|\x1B\x24[^\x29]|\x1B\x24\x29C/;
53              return (charset => 'iso-2022-cn') unless $s =~ /\x1B[^\x24\x28]|\x1B\x24[^B]|\x1B\x28[^A]|\x1B\x24\x28[^GH]|\x0E|\x0F/;
54              (charset => 'iso-2022-int-1');
55            },
56                    
57          mime_text       => 1,          mime_text       => 1,
58  };  };
# Line 53  $CHARSET{'unknown-8bit'} = { Line 64  $CHARSET{'unknown-8bit'} = {
64          decoder => sub { $_[1] },          decoder => sub { $_[1] },
65                    
66          mime_text       => 0,          mime_text       => 0,
67          cte_7bit_preferred      => 'quoted-printable',          cte_7bit_preferred      => 'base64',
68  };  };
69  $CHARSET{'x-unknown'} = $CHARSET{'unknown-8bit'};  $CHARSET{'x-unknown'} = $CHARSET{'unknown-8bit'};
70    
# Line 61  sub make_charset ($%) { Line 72  sub make_charset ($%) {
72    my $name = shift;    my $name = shift;
73    return unless $name;  ## Note: charset "0" is not supported.    return unless $name;  ## Note: charset "0" is not supported.
74    my %definition = @_;    my %definition = @_;
75      
76      $definition{preferred_name} ||= $name;
77    if ($definition{preferred_name} ne $name    if ($definition{preferred_name} ne $name
78        && ref $CHARSET{$definition{preferred_name}}) {        && ref $CHARSET{$definition{preferred_name}}) {
79    ## New charset is an alias of defined charset,    ## New charset is an alias of defined charset,
# Line 74  sub make_charset ($%) { Line 87  sub make_charset ($%) {
87    $CHARSET{$name} = \%definition;    $CHARSET{$name} = \%definition;
88        
89    ## Set default values    ## Set default values
90    $definition{preferred_name} ||= $name;    #$definition{encoder} ||= sub { $_[1] };
91        #$definition{decoder} ||= sub { $_[1] };
   $definition{encoder} ||= sub { $_[1] };  
   $definition{decoder} ||= sub { $_[1] };  
92    
93    $definition{mime_text} = 0 unless defined $definition{mime_text};    $definition{mime_text} = 0 unless defined $definition{mime_text};
94    $definition{cte_7bit_preferred} = 'base64'    $definition{cte_7bit_preferred} = 'base64'
# Line 105  sub name_normalize ($) { Line 116  sub name_normalize ($) {
116    $CHARSET{$name}->{preferred_name} || $name;    $CHARSET{$name}->{preferred_name} || $name;
117  }  }
118    
119    sub name_minimumize ($$) {
120      my ($charset, $s) = (lc shift, shift);
121      if (ref $CHARSET{$charset}->{name_minimumizer}) {
122        return &{$CHARSET{$charset}->{name_minimumizer}} ($charset, $s);
123      }
124      $charset;
125    }
126    
127  =head1 LICENSE  =head1 LICENSE
128    
129  Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.  Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24