[HOME] [NSRG] [インフラ] [fml4] [fml8] [北海道] [おすすめの本] Powered by NetBSD and [nuinui.net] .

run_in_chcode()

In language dependent processes, convert the charset to machine friendly one, process something and back it to the original chaset each time. This step is widely used. So it is convenient to prepare a function to pack these steps into one function.

run_in_chcode example:

sub run_in_chcode
{
   my ($self, $proc, $s, $out_code, $in_code) = @_;

   my $conv_status = convert_str_ref($s, $EUC_JP, $in_code);
   my $proc_status = &$proc($s, @_);
   convert_str_ref($s, $out_code, $EUC_JP) if $conv_status && $out_code;
   return wantarray ? ($conv_status, $proc_status): $conv_status;
}

[HOME] [NSRG] [インフラ] [fml4] [fml8] [北海道] [おすすめの本] Powered by NetBSD and [nuinui.net] .
Copyright (C) 1993-2017 Ken'ichi Fukamachi mail:< fukachan at fml.org >