下面的代碼爲什麼在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