Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have PERL_UNICODE set to SDL, ${^UNICODE} reports back 95.(¹)
This is really comfy for my UTF8 locale, as filehandles and STDFOO are already marked as :utf8 or something(²) and the utf8-related warnings disappear and that allows me to be more lazy while programming, especially for oneliners.
But I cannot get rid of this one which happens whenever I pass a descriptive string to Test::More's ok() with characters whose ord() > 255.(³)
$ perl -e'use Test::More tests => 1; ok 1, "\x{2639}";' 1..1 Wide character in print at /usr/lib/perl5/5.8.8/Test/Builder.pm line 1 +172. ok 1 - ☹
I tried to track down the cause of that(⁴) and suspect it's the way filehandles are set up at Test/Builder.pm ll. 1317. I managed to reproduce a minimal test case in the debugger.
$ perl -d -e0 Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 0 + DB<1> open(TESTOUT, ">&STDOUT") or die "Can' +t dup STDOUT: $!"; + DB<2> $fh = \*TESTOUT; + DB<3> print $fh "\x{2639}"; Wide character in print at (eval 23)[/usr/lib/perl5/5.8.8/perl5db.pl:6 +28] line 2. at (eval 23)[/usr/lib/perl5/5.8.8/perl5db.pl:628] line 2 eval '($@, $!, $^E, $,, $/, $\\, $^W) = @saved;package main; $ +^D = $^D | $DB::db_stop; print $fh "\\x{2639}";; ;' called at /usr/lib/perl5/5.8.8/perl5db.pl line 628 DB::eval called at /usr/lib/perl5/5.8.8/perl5db.pl line 3412 DB::DB called at -e line 1 + DB<4> ☹
However, if I put these three lines into perl -e or a file and run it, I do not get the warning at all. Strange, huh?
(¹) See perlrun and perlvar.
(²) How do I know what modes lie on a filehandle, anyway? PerlIO::get_layers always just returns qw(unix perlio) which is too little to be possibly true.
(³) Actually I use utf8; and have literal characters in that string instead of \x escaped, but it doesn't matter.
(⁴) And in the cause of that found an orkaround for the problem: binmode Test::More->builder->output, ':utf8';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: bug? duped filehandles and unicode
by Joost (Canon) on May 12, 2007 at 20:03 UTC | |
|
Re: bug? duped filehandles and unicode
by Khen1950fx (Canon) on May 12, 2007 at 23:24 UTC | |
|
Re: bug? duped filehandles and unicode
by Burak (Chaplain) on May 14, 2007 at 10:14 UTC |