use utf8; binmode STDOUT, ':utf8'; binmode STDIN, ':utf8'; use strict; use Encode; sub main(){ #UTF-8(BOMなし),CRLFのファイルに書いてます。 my $str = "あ"; my $bin = $str; $bin = Encode::encode('euc-jp', Encode::decode('utf8', $str)); $bin = Encode::encode('utf8', Encode::decode('euc-jp', $bin)); print "Content-Type:text/plain;charset=UTF-8\n"; print "\n"; print $bin; } &main; ======================= 希望する出力結果: あ
![Cannot decode string with wide characters](https://cdn-ak-scissors.b.st-hatena.com/image/square/96b6f7e41f80711497997e6f0a65ab362eda9904/height=288;version=1;width=512/https%3A%2F%2Foshiete.xgoo.jp%2Fimages%2Fsp%2Fqa_recommend%2F2101_3.jpg)