[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?
From: |
Greg Wooledge |
Subject: |
Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z? |
Date: |
Mon, 21 May 2012 08:38:19 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Sun, May 20, 2012 at 11:36:35AM -0700, Linda Walsh wrote:
> Anyway... so WHY does bash collate this way?
It doesn't. The operating system does. Bash just calls upon the C
library's strcoll(3) routine.
The results vary across operating systems, and even potentially across
locale definitions within a given OS implementation.
> Under what rules is bash
> operating? I.e. justification?
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html
In particular, LC_COLLATE starts at
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_02
> If other programs claim to have locale specific sorting & character
> collation, should they be sorting the same way?
Yes. ls(1) for example sorts filenames according to the collation
order defined in the current locale (LC_ALL or LC_COLLATE or LANG).
You should get the same sorting from both ls and *.
For instance, on HP-UX 10.20, in the en_US.iso88591 locale:
imadev:~$ mkdir /tmp/greg && cd "$_"
imadev:/tmp/greg$ touch a A á Á à À â Â ä Ä b B
imadev:/tmp/greg$ ls
A a Á á À à Â â Ä ä B b
imadev:/tmp/greg$ echo *
A a Á á À à Â â Ä ä B b
imadev:/tmp/greg$ LC_COLLATE=C ls
A B a b À Á Â Ä à á â ä
imadev:/tmp/greg$ LC_COLLATE=C; echo *; unset LC_COLLATE
A B a b À Á Â Ä à á â ä
Meanwhile, on Debian 6.0, in the en_US.iso88591 locale:
arc3:~$ mkdir /tmp/greg && cd "$_"
arc3:/tmp/greg$ touch a A á Á à À â Â ä Ä b B
arc3:/tmp/greg$ echo *
a A á Á à À â Â ä Ä b B
As you can see, the two en_US.iso88591 implementations are not the same.
See http://mywiki.wooledge.org/locale or myriad other resources (including
the POSIX page linked earlier) for further explanations.
- locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Linda Walsh, 2012/05/20
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?,
Greg Wooledge <=
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Linda Walsh, 2012/05/21
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Chris F.A. Johnson, 2012/05/21
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Greg Wooledge, 2012/05/21
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Linda Walsh, 2012/05/21
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Chet Ramey, 2012/05/21
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Linda Walsh, 2012/05/21
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Eric Blake, 2012/05/21
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Linda Walsh, 2012/05/21
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Chet Ramey, 2012/05/21
- Re: locale specific ordering in EN_US -- why is a<A<b<B<y<Y<z<Z?, Eric Blake, 2012/05/21