1

我正在尝试编写一个小的Log::Any::Adapter用于 Wx 日志记录,并且为了测试我正在使用 Wx 的LogStderr类。但是,我的测试失败了,因为打印到 STDERR 的字符串将所有其他字符都设为 NULL。我认为它可能是 UTF-16le,因为我在 Windows 上。我知道我能做到

decode('UTF-16le', $_)

但是有没有办法可以确定编码以便代码适用于所有系统?

我的尝试:

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');

我会粘贴输出,但是对于所有 NUL,我无法将其复制到我的剪贴板上!

4

0 回答 0