Hi all,

The following code:

  use utf8; 
  use diagnostics;
  BEGIN {binmode STDOUT, ':utf8';}
  use Test::More tests => 1;
  # those are smart quotes
  diag "This is a \x{201c}test\x{201d}";
  ok 1;

Produces the following error message:

  1..1
  Wide character in print at /usr/local/lib/perl5/5.8.5/Test/Builder.pm
line 1005 (#1)
    (W utf8) Perl met a wide character (>255) when it wasn't expecting
    one.  This warning is by default on for I/O (like print).  The
easiest
    way to quiet this warning is simply to add the :utf8 layer to the
    output, e.g. binmode STDOUT, ':utf8'.  Another way to turn off the
    warning is to add no warnings 'utf8'; but that is often closer to
    cheating.  In general, you are supposed to explicitly mark the
    filehandle with an encoding, see open and perlfunc/binmode.
    
  # This is a “test”
  ok 1

And looking at line 1005:

  sub _print_diag {
    my $self = shift;

    local($\, $", $,) = (undef, ' ', '');
    my $fh = $self->todo ? $self->todo_output : $self->failure_output;
    print $fh @_; # here there be smart quotes
  }

There are a few strange paths in the code which could be causing this
(I'm wondering about the autoflush), but I was wondering if anyone has
seen this and knows how to cope with it?  As you can see, I've tried
that standard binmode ':utf8' and using utf8, but to no avail.  

Cheers,
Ovid

=====
Silence is Evil            
http://users.easystreet.com/ovid/philosophy/decency.html
Ovid                       http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

Reply via email to