GrandFather has asked for the wisdom of the Perl Monks concerning the following question:
I have a test script that is "doing the right thing", but is generating a warning.
use strict; use warnings; use utf8; my $str = "采样速率太高"; my $output2; open OUTVAR2, '>', \$output2; print OUTVAR2 $str; close OUTVAR2; print "\n$output2"; print "\n$str";
Prints:
采样速率太高 Wide character in print at noname2.pl line 9. 采样速率太高 Wide character in print at noname2.pl line 13.
Changing the open to use '>:utf8' fixes the line 9 warning, but leaves the line 13 warning. Adding binmode STDOUT, 'utf8'; fixes the line 13 warning, but now the output becomes:
éæ ·éçå¤ªé« 采样速率太高
How do I clean up the warnings and retain the correct output?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: utf8 encoding and warnings woe
by ikegami (Patriarch) on Oct 31, 2006 at 02:07 UTC | |
|
Re: utf8 encoding and warnings woe
by graff (Chancellor) on Oct 31, 2006 at 01:40 UTC | |
by GrandFather (Saint) on Oct 31, 2006 at 02:18 UTC | |
by GrandFather (Saint) on Oct 31, 2006 at 01:53 UTC |