2012-01-12から1日間の記事一覧

utf8フラグ付だとlengthは文字数を返す

マルチバイト文字の文字数カウント方法を調べたが、これが最もシンプルなり。 use strict; use warnings; use Encode qw(decode); my $str = 'あいうえお'; warn length($str); # 10 warn length(decode("euc-jp", $str)); # 5 便利!