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> &#9785;

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';


In reply to bug? duped filehandles and unicode by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.