I ran into the exact same problem while testing
Perl6::Str, and I worked around it with the following sub, through which I piped all my output to diag(). It doesn't display the non-ASCII-Characters, but it does enable very detailed analysis even on non-utf-8 terminals:
use charnames ();
sub escape_str {
my $str = shift;
$str =~ s{([^\0-\177])}{_N_escape($1)}eg;
return $str;
}
sub _N_escape {
return '\N{' . charnames::viacode(ord($_[0])) . '}';
}
However your post encouraged me to dig into Test::More source code, and in Test::Builder I found this code:
sub _print_diag {
my $self = shift;
local($\, $", $,) = (undef, ' ', '');
my $fh = $self->todo ? $self->todo_output : $self->failure_output;
print $fh @_;
}
So it seems you have to get hold of a test builder object, and then binmode todo_output or failure_output (or both):
$ perl -MTest::More -wle 'binmode Test::More->builder->failure_output,
+ ":utf8"; diag chr(228)'
# ä
Not pretty, but it works.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.