本体はプライベートメソッド _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 する。
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>.