diff options
| author | dangofactory (ketsuban) <ketsuban@dangofactory.net> | 2026-10-03 16:51:23 +0900 |
|---|---|---|
| committer | dangofactory (ketsuban) <ketsuban@dangofactory.net> | 2026-10-03 16:51:23 +0900 |
| commit | 94db2cd25d5bd75ee9d1c908a231db425b87c7c6 (patch) | |
| tree | 36b17fc742a3c832a221eae7d9361368d728a30f /fml | |
| parent | b00fc171444010ad80ec54fbfd0335de7fefc865 (diff) | |
| download | fml8-94db2cd25d5bd75ee9d1c908a231db425b87c7c6.tar.gz fml8-94db2cd25d5bd75ee9d1c908a231db425b87c7c6.tar.bz2 fml8-94db2cd25d5bd75ee9d1c908a231db425b87c7c6.zip | |
Encode: decode via Unicode::Japanese getcode() only, dropping the in_code/_jp_str_ref path
Applied to the installed tree at
/usr/local/lib/fml/current-20260601 (the fml_version in
/usr/local/etc/fml/main.cf), which is what the dev-list@dangofactory.net
mailing list actually loads.
Upstream file: fml/lib/Mail/Message/Encode.pm
Host copy: /usr/local/lib/fml/current-20260601/Mail/Message/Encode.pm
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/Mail/Message/Encode.pm | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/fml/lib/Mail/Message/Encode.pm b/fml/lib/Mail/Message/Encode.pm index 346ae3b6..7b45aadd 100644 --- a/fml/lib/Mail/Message/Encode.pm +++ b/fml/lib/Mail/Message/Encode.pm @@ -88,23 +88,22 @@ sub detect_code my ($self, $str) = @_; my $lang = $self->{ _language }; - # XXX Japanese includes English. if ($lang eq 'japanese' || $lang eq 'english') { - # getcode() can detect the follogin code: - # jis, sjis, euc, utf8, ucs2, ucs4, utf16, utf16-ge, utf16-le, - # utf32, utf32-ge, utf32-le, ascii, binary, sjis-imode, - # sjis-doti, sjis-jsky. - use Unicode::Japanese; - my $obj = new Unicode::Japanese; - return $obj->getcode($str); + + my $hex = unpack('H*', $str); + + use Unicode::Japanese; + my $obj = new Unicode::Japanese; + my $code = $obj->getcode($str); + + return $code; } else { - carp("Mail::Message::Encode: unknown language"); - return 'unknown'; + carp("Mail::Message::Encode: unknown language"); + return 'unknown'; } } - # Unicode::Japanese # 'jis', 'sjis', 'euc', 'utf8', 'ucs2', 'ucs4', 'utf16', # 'utf16-ge', 'utf16-le', 'utf32', 'utf32-ge', @@ -156,35 +155,33 @@ sub convert_str_ref my $lang = $self->{ _language }; unless (ref($str_ref) eq 'SCALAR') { - croak("convert_str_ref: invalid input data"); + croak("convert_str_ref: invalid input data"); } - # XXX Japanese includes English. if ($lang eq 'japanese' || $lang eq 'english') { - # 1. if the encoding for the given $str_ref is unknown, return ASAP. - unless (defined $in_code) { - $in_code = $self->detect_code($$str_ref); - if ($in_code eq 'unknown') { - return 0; - } - } - else { - # print "1 ok\n"; - } - - # 2. try conversion ! (converted to 'euc' by default). - if ($in_code) { - return $self->_jp_str_ref($str_ref, $out_code, $in_code); - } - } - else { - croak("Mail::Message::Encode: unknown language"); + + unless (defined $in_code) { + $in_code = $self->detect_code($$str_ref); + + if ($in_code eq 'unknown') { + return 0; + } + } + + if ($in_code) { + my $r = $self->_jp_str_ref( + $str_ref, + $out_code, + $in_code + ); + + return $r; + } } return 0; } - # Descriptions: convert japanese string to $out_code. # XXX $in_code must be determined here ! # Arguments: OBJ($self) STR_REF($str_ref) STR($out_code) STR($in_code) @@ -195,25 +192,28 @@ sub _jp_str_ref my ($self, $str_ref, $out_code, $in_code) = @_; if ($out_code =~ /^(jis|sjis|euc)$|^(jis|sjis|euc)[-_]jp$/i) { - my $code = $1 || $2; - $code =~ tr/A-Z/a-z/; - use Jcode; - &Jcode::convert($str_ref, $code, $in_code); + my $code = $1 || $2; + $code =~ tr/A-Z/a-z/; - return 1; + use Jcode; + &Jcode::convert($str_ref, $code, $in_code); + + return 1; } elsif ($out_code =~ /^(iso2022jp|iso-2022-jp)$/i) { - use Jcode; - &Jcode::convert($str_ref, 'jis', $in_code); - return 1; + use Jcode; + &Jcode::convert($str_ref, 'jis', $in_code); + + return 1; } + warn "_jp_str_ref: unsupported out_code=$out_code\n"; + return 0; } - =head2 run_in_code($proc, $s, $args, $out_code, $in_code) run $proc($s) under $out_code environment. |
