- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
下面的代码
#!/usr/bin/perl
use strict;
use warnings;
my $s1 = 'aaa2000@yahoo.com';
my $s2 = 'aaa_2000@yahoo.com';
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:
aaa2000@yahoo.com is < aaa_2000@yahoo.com
aaa2000 is < aaa_2000
With 'use locale;':
aaa2000@yahoo.com is > aaa_2000@yahoo.com
aaa2000 is < aaa_2000
我无法真正理解:在同一时间,在使用语言环境下,有一个 AND a@yahoo.com > b@yahoo.com ? !!
我是否遗漏了或多或少明显的东西,或者这是一个错误?其他人能否确认看到相同的行为?
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=
提前致谢。
最佳答案
启用语言环境后,整理会分多次进行。每个角色都有四个权重,在连续的传递中进行比较。 @
和 _
符号与大多数标点符号一样,没有主要、次要或第三次重量,因此它们仅在第四遍中发挥作用。所以,对于你的例子
aaa2000@yahoo.com > aaa_2000@yahoo.com
第一关,真的是比较
aaa2000yahoocom = aaa2000yahoocom
然后在第四遍(第二遍和第三遍没有区别因素)
@. > _@.
因为 @
在这个语言环境中恰好大于 _
。 (这只是语言环境定义做出的选择,大概基于某些 ISO 标准或其他标准。)
您可以查看其实现细节。启用语言环境的比较最终在 C 库中实现为 strxfrm(A) cmp strxfrm(B)
。运行这个程序:
use POSIX;
my $s1 = 'aaa2000@yahoo.com';
my $s2 = 'aaa_2000@yahoo.com';
foreach ($s1, $s2) {
printf "%s =>\t%v02x\n", $_, POSIX::strxfrm($_);
}
我得到:
aaa2000@yahoo.com => 0c.0c.0c.04.02.02.02.24.0c.13.1a.1a.0e.1a.18.01.08.08.08.08.08.08.08.08.08.08.08.08.08.08.08.01.02.02.02.02.02.02.02.02.02.02.02.02.02.02.02.01.08.5d.06.44
# explanation: a a a 2 0 0 0 y a h o o c o m DIV secondary weights ... DIV tertiary weights ... DIV @ .
aaa_2000@yahoo.com => 0c.0c.0c.04.02.02.02.24.0c.13.1a.1a.0e.1a.18.01.08.08.08.08.08.08.08.08.08.08.08.08.08.08.08.01.02.02.02.02.02.02.02.02.02.02.02.02.02.02.02.01.04.36.05.5d.06.44
# explanation: a a a 2 0 0 0 y a h o o c o m DIV secondary weights ... DIV tertiary weights ... DIV _ @ .
这些数字的派生方式是一个实现细节;他们只需要出来使得字节比较产生所需的最终结果。但这个概念在所有支持区域设置的排序的现代编程环境中都是相同的。
关于c - 为什么附加公共(public)后缀会反转 en_US 语言环境中的整理顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3979576/
我正在尝试将我在本文档中阅读的内容付诸实践: https://sar.informatik.hu-berlin.de/research/publications/SAR-PR-2006-05/SAR-
我一直在尝试编写一个可以改变这个的 terraform 表达式: subnets = { my_subnet_1 = { nsg = "my_nsg_1", ad
我有一个HashMap,它将两个字符串转换为单词,然后将单词添加到 map 中。我拥有它,以便一个键可以指向多个值。现在我想创建一个循环来反转表,以便所有值都指向键。不要为一个指向多个逆值的键而烦恼。
我对 ~ 运算符有点困惑。代码如下: a = 1 ~a #-2 b = 15 ~b #-16 ~ 是如何工作的? 我想,~a 会是这样的: 0001 = a 1110 = ~a 为什么不呢? 最佳
如果执行 ResourceManager.GetString(Key),您可以获取资源中某个项目的值。有没有一种方法可以进行反向查找以从给定值的资源中获取 key (本质上是反翻译)? 最佳答案 您应
我在 R 中编写了一个代码来反转一个数字。但是我得到了 inf作为输出。 digit0){ rev_num=rev_num*10 + digit %% 10 digit=digit / 10 }
这个问题已经有答案了: Invert keys and values of the original dictionary (3 个回答) 已关闭 9 年前。 我正在寻找在 python 上转置一本字
所以我试图反转我当前制作的形状的输出。我想知道我应该扭转这种情况吗?我尝试更改变量“a”和“c”的值,最终陷入无限循环。 class IRT { public static void main
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: PHP mysql_real_escape_string() -> stripslashes() leavi
从 Wordpress 模板中提取一些预先存在的代码来绘制椭圆阴影。阴影呈椭圆形向下辐射。只有椭圆的下半部分可见,从而形成底部阴影效果。 我只是想“反转”椭圆的“阴影效果”,以便只有阴影的顶部 一半可
我有一个函数应该找到两个弧度的中间 function mrad(rb,ra){return (rb+ra)/2;} 但有时,当我用 Math.sin 和 Math.cos 绘制 x 和 y 时,这两个
给定此代码(http://jsfiddle.net/bzf1mkx5/) .intern { -webkit-animation: in 1s 1 reverse forwards; } .i
我对 ~ 运算符有点困惑。代码如下: a = 1 ~a #-2 b = 15 ~b #-16 ~ 是如何工作的? 我想,~a 会是这样的: 0001 = a 1110 = ~a 为什么不呢? 最佳
我需要以相反的顺序从列表中提取项目(从最后一个条目到第一个)。我设法得到了所有元素,但是,从第一个到最后一个。这是我正在使用的部分代码: 该列表位于不同的网站集上。 using (SPSit
由于一些证书问题,我不得不写 ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chai
是否有一个函数接受一个函数列表和一个输入,并输出一个对输入进行操作的函数列表? 所以像 map,但倒退: >>>map(lambda x: 2*x,[1,2,3,4,5,6,7,8,9]) [2, 4
考虑下表团队消息: 15:10 | Peter | I'm off to the store, call my mobile phone if you need me. 15:11 | Susy |
算法如下: int encryption(int a, int b) { short int c, c2; uint8_t d; c = a ^ b; c2 = c;
我正在寻找一种方法来逆转 a CRC32 checksum .周围有解决方案,但它们要么是 badly written , extremely technical和/或 in Assembly .汇编
使用批处理文件,处理所有在文件名或扩展名中共享字符串的文件就足够简单了,例如: FOR /R %F IN (*.EXE) DO @ECHO %F 但是,如果我想反转文件集的含义怎么办?比如,处理所有不
我是一名优秀的程序员,十分优秀!