#b1.pl use strict; use utf8; $_="中文"; sub p{ my $_=shift; binmode STDOUT, ":encoding(gbk)"; print "$_\n"; } p($_); p($_); __END__
#b2.pl use strict; use utf8; $_="中文"; binmode STDOUT, ":encoding(gbk)"; print "$_\n";
In the scripts, 中文 are two chinese characters, which are transformed by perlmonks.In my imagination, the two scripts should have the same output. However, after run under windows xp(chinese edition, edition of perl is activeperl v5.12.2 built for MSWin32-x86-multi-thread), the two scripts have differnt outputs:binmode STDOUT, ":encoding(gbk)"; print "$_\n"; __END__
I don't have any idea that why the outputs of the two scripts are different. Can any body give me some hints? Thanks.e:\home\pl>perl b1.pl perl b1.pl 中文 "\x{0590}" does not map to cp936. "\x{0384}" does not map to cp936. \x{0590}\x{0384} e:\home\pl>perl b2.pl perl b2.pl 中文 中文
Thanks to Anynymous Monk. "encodinig" in b2.pl is my stupid typo, I've corrected it.
In reply to weird behaviour of binmode by enroute
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |