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/2217b5f8fd432f1f8e24e3387bf58ef8f86ddb50/height=288;version=1;width=512/https%3A%2F%2Foshiete.xgoo.jp%2Fimages%2Fsp%2Fqa_recommend%2F2101_4.jpg)