下面的代码为什么在en_US区域设置中添加通用后缀会颠倒整理顺序?
#!/usr/bin/perl
use strict;
use warnings;
my $s1 = '[email protected]';
my $s2 = '[email protected]';
my $s3 = 'aaa2000';
my $s4 = 'aaa_2000';
no locale;
print "\nNO Locale:\n\n";
if ($s1 gt $s2) {print "$s1 is > $s2\n";}
if ($s1 lt $s2) {print "$s1 is < $s2\n";}
if ($s1 eq $s2) {print "$s1 is = $s2\n";}
if ($s3 gt $s4) {print "$s3 is > $s4\n";}
if ($s3 lt $s4) {print "$s3 is < $s4\n";}
if ($s3 eq $s4) {print "$s3 is = $s4\n";}
use locale;
print "\nWith 'use locale;':\n\n";
if ($s1 gt $s2) {print "$s1 is > $s2\n";}
if ($s1 lt $s2) {print "$s1 is < $s2\n";}
if ($s1 eq $s2) {print "$s1 is = $s2\n";}
if ($s3 gt $s4) {print "$s3 is > $s4\n";}
if ($s3 lt $s4) {print "$s3 is < $s4\n";}
if ($s3 eq $s4) {print "$s3 is = $s4\n";}
打印出
NO Locale:
[email protected] is < [email protected]
aaa2000 is < aaa_2000
With 'use locale;':
[email protected] is > [email protected]
aaa2000 is < aaa_2000
我不能真正遵循:在同时,在使用现场,有一个< b 和一个@雅虎。 com> [email protected]?!!
我错过了一些或多或少明显的东西,还是这是一个错误?其他人可以确认看到相同的行为吗?
Locale is $ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
在此先感谢。
您只是描述了Unicode排序算法。这不是一个真正的地方。但是我相信UCA有或没有本地化模块比我曾经信任过的供应商本地化模块多一百万倍。那些对我来说总是失败。现在我们已经有了Unicode,所以我非常强烈地认为/ opine语言环境不适用于ctype/collate目的的传统bandaides。 – tchrist 2011-08-27 15:11:03
不,我正在描述他的系统的实际情况,因为它适用于他的问题。我怀疑现在大多数供应商都是基于UCA实施他们的区域设置;毕竟UCA不是凭空发明的。但我没有看到你的观点为什么区域设置失败或应该被视为遗留问题。当然,只要语言偏离“默认”排序,您就需要语言特定的排序规则。但这个问题的确非常重要。 – 2011-08-28 09:03:08