加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-16 06:23:20 所属栏目:大数据 来源:网络整理
导读:我有以下测试: 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 = 'Li
我有以下测试:

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;

在Mac OS X上使用Perl 5.10.1,我得到以下输出:

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,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 :: NameCase使用语言环境;因此它使用当前的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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读