in reply to How can I enable utf8 layer on Test::More diag output
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):
Not pretty, but it works.$ perl -MTest::More -wle 'binmode Test::More->builder->failure_output, + ":utf8"; diag chr(228)' # ä
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I enable utf8 layer on Test::More diag output
by mje (Curate) on Jul 22, 2008 at 15:03 UTC | |
by moritz (Cardinal) on Jul 22, 2008 at 15:10 UTC | |
by mje (Curate) on Jul 22, 2008 at 15:16 UTC |