gpt4 book ai didi

OS X 上的 Perl Unicode 测试在 Debian 上失败

转载 作者:行者123 更新时间:2023-12-05 00:28:34 25 4
gpt4 key购买 nike

我有以下测试:

use Test::More;
use Lingua::EN::NameCase 'nc';
use utf8;
my $output = Test::Builder->new->todo_output;
binmode $output, ':encoding(UTF-8)';
$output = Test::Builder->new->failure_output;
binmode $output, ':encoding(UTF-8)';

my $name = 'Lintão';
is nc($name), $name, 'nc() should not change a properly namecased name';
diag nc($name);

done_testing;

在使用 Perl 5.10.1 的 Mac OS X 上,我得到以下输出:
nc.t ..
ok 1 - nc() should not change a properly namecased name
1..1
# Lintão
ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.04 cusr 0.00 csys = 0.07 CPU)
Result: PASS

不幸的是,在 Debian Squeezebox 上使用 5.10.1 Perl 进行的相同测试会产生以下输出:
nc.t ..
not ok 1 - nc() should not change a properly namecased name

# Failed test 'nc() should not change a properly namecased name'
# at nc.t line 10.
# got: 'LintãO'
# expected: 'Lintão'
# LintãO
1..1
# Looks like you failed 1 test of 1.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests

Test Summary Report
-------------------
nc.t (Wstat: 256 Tests: 1 Failed: 1)
Failed test: 1
Non-zero exit status: 1
Files=1, Tests=1, 0 wallclock secs ( 0.01 usr 0.00 sys + 0.03 cusr 0.00 csys = 0.04 CPU)
Result: FAIL
nc() 中的违规行子程序似乎是这样的:
s{ \b (\w)   }{\u$1}gox ;           # Uppercase first letter of every word.

所以不知何故,Debian 上的相同版本的 Perl 把词边界弄错了。谁能帮我进一步调试?

最佳答案

Linux 机器上的语言环境不考虑 ã一个单词字符( Lingua::EN::NameCaseuse locale; 所以它使用当前的 LC_CTYPE 设置进行字符分类)。使用 perlbrewed perls 范围从 5.8.1 到 5.18.1,我在 Ubuntu 12.04 LTS 上使用 en_GB.UTF-8 持续获得此输出语言环境:

$ perl -Mutf8 -le 'print 0+("ã" =~ /\w/); use locale; print 0+("ã" =~ /\w/)'
1
0

关于OS X 上的 Perl Unicode 测试在 Debian 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18827733/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com