I'm trying to write a small Log::Any::Adapter for Wx logging, and for testing I'm using Wx's LogStderr class. My test fails, though, because the string printed to STDERR has every other character as a NULL. I figure that it's probably UTF-16le since I'm on Windows. I know I can do
decode('UTF-16le', $_)
but is there a way I can determine the encoding so the code works on all systems?
My attempt:
use strict;
use warnings;
use Test::More tests => 1;
use Wx;
use Capture::Tiny qw(capture_stderr);
use Encode::Locale;
use Encode qw(decode);
Wx::Log::SetActiveTarget(Wx::LogStderr->new());
my $stderr = capture_stderr { Wx::LogMessage('hello!') };
$stderr = decode(console_in => $stderr); #doesn't work; still has NUL's
like($stderr, qr/hello!/, 'Wx logs correctly to STDERR');
I'd paste the output, but with all of the NULs I can't get it to copy onto my clipboard!