Discussion:
Unicode output with Test::More
Olivier Mengué
2014-02-15 15:22:59 UTC
Permalink
Hi,

I would like to use non-ASCII, non-Latin-1 characters in test script output.

So far I've written the following:

use Test::More;
use Term::Encoding 'term_encoding';
my $enc = term_encoding();
note $enc; # Ensure that builder->output is opened
binmode($_, ":encoding($enc)")

for Test::More->builder->output;


Is there a better way (cleaner, or more portable)?
Does something already exists on CPAN?

Thanks for you help,

PS: for my full use case, see
https://github.com/dolmen/angel-PS1/blob/85912c6fe5d2f9507cb1831c689fe66db4ec7bcc/t/52-Gauges.t


Olivier Mengué (DOLMEN)
Mike Doherty
2014-02-15 16:44:07 UTC
Permalink
IIRC, Test::More::UTF8 does the right thing.

-Mike
Post by Olivier Mengué
Hi,
I would like to use non-ASCII, non-Latin-1 characters in test script output.
use Test::More;
use Term::Encoding 'term_encoding';
my $enc = term_encoding();
note $enc; # Ensure that builder->output is opened
binmode($_, ":encoding($enc)")
for Test::More->builder->output;
Is there a better way (cleaner, or more portable)?
Does something already exists on CPAN?
Thanks for you help,
PS: for my full use case, see
https://github.com/dolmen/angel-PS1/blob/85912c6fe5d2f9507cb1831c689fe66db4ec7bcc/t/52-Gauges.t
Olivier Mengué (DOLMEN)
Karen Etheridge
2014-02-15 17:25:27 UTC
Permalink
Post by Olivier Mengué
Hi,
I would like to use non-ASCII, non-Latin-1 characters in test script output.
use Test::More;
use Term::Encoding 'term_encoding';
my $enc = term_encoding();
note $enc; # Ensure that builder->output is opened
binmode($_, ":encoding($enc)")
for Test::More->builder->output;
I just do this in tests which deal with utf8 content:

use utf8;
binmode $_, ':utf8' foreach map { Test::Builder->new->$_ } qw(output failure_output);

It would certainly be nice if there were a more direct interface to set the
binmode of all handles at once.

Loading...