バイト数ではなく、文字数でカウントされることに注意してください。
▲Windows XP Professional Service Pack 3
ActivePerl 5.8.8 Build 822
Encode-2.33
処理の結果は、shiftjis で出力されます。
スクリプトは utf8 で保存してください。
#!/usr/local/bin/perl
use utf8;
use strict;
use Encode;
binmode STDOUT, ":encoding(shiftjis)";
# 変数の設定
my $e_b_text = '子丑寅卯辰巳午未申酉戌亥';
# 文字列の長さを表示
print length($e_b_text);
12 と表示されます。
Powered by NIVOSIdE