Chapter 52. Mail::Message::Encode クラス

Table of Contents
Mail::Message::Encode の仕様
run_in_chcode()

[リファレンス] fml-help ML's Count: 02012, 02013, 02016 など

[使い方の例]

	use Mail::Message::Encode;
	my $encode  = new Mail::Message::Encode;
	my $str_euc = $encode->convert( $s, 'euc-jp' );
	my $str_euc = $encode->convert( $s, 'euc-jp', 'iso-2022-jp' );

	my $encode  = new Mail::Message::Encode;
	my $status  = $encode->convert_str_ref( \$s, 'euc-jp' );
	my $status  = $encode->convert_str_ref( \$s, 'euc-jp', 'jis' );

	my $fp = sub { ... };
	$encode->run_in_chcode( $fp, $oout, $in );

   * 4.0 互換
	ues Mail::Message::Encode qw(STR2EUC);
	my $euc_s = STR2EUC( $s );

Mail::Message::Encode の仕様

本体は _convert_str_ref() にまとめる。

   sub convert # 引数が STR
   {
	my ($self, $str, $out_code, $in_code) = @_;
	_convert_str_ref(\$str, $out, $in);

        return $str;
   }


   sub convert_str_ref # 引数が STR_REF
   {
	my ($self, $str, $out, $in) = @_;
	_convert_str_ref($str, $out, $in);
   }


   sub _convert_str_ref # 引数が STR_REF
   {
        my ($str, $out, $in) = @_;

        # 1. 推測
        もし $in がない → 推測 → 失敗 → 0 をかえす? 

        # 2. 変換をトライ
        if ($in がわかった or $in が指定された) {
                $out へ変換
                jcode, Jcode, Encode は perl バージョンによって
                よろしく変換をがんばる
                return 1 ; #成功
        }
        else { # principle of least surprise ?
                なにもしない# str はそのまま返す
        }

        return 0 ; # 失敗
   }
sub base64 {}
sub quoted_printable {}
があるといいかな〜
$x = $encode->base64($s);
また、互換性というか便宜上、STR2XXX() も準備する。
   STR2EUC(  $str, [$icode] )
   STR2JIS(  $str, [$icode] )
   STR2SJIS( $str, [$icode] )
は convert_str_ref を wrap する。

fml 8.0 (fml-devel) project homepage is www.fml.org/software/fml-devel/.
fml 4.0 project homepage is www.fml.org/fml/menu.ja.html.
about one floppy bsd routers, see www.bsdrouter.org/.
other free softwares are found at www.fml.org/software/.

author's homepage is www.fml.org/home/fukachan/.
Also, visit nuinui's world :) at www.nuinui.net.

For questions about FML, e-mail <fml-bugs@fml.org>.