Re: Chiffres romains, locale et tri
* Jacques L'helgoualc'h <lhh+no_spam@free.fr> [2005-06-19 15:10] :
> François TOURDE a écrit, dimanche 19 juin 2005, à 13:42 :
> > Jacques L'helgoualc'h écrivait:
> [...]
> > > $ LC_ALL=fr_FR sort fichier
> > > Dvorak_Symphony_n°7_in_D_Minor_op.70_I-Allegro
> > > Dvorak_Symphony_n°7_in_D_Minor_op.70_III-Scherzo
> > > Dvorak_Symphony_n°7_in_D_Minor_op.70_II-Poco
> > > Dvorak_Symphony_n°7_in_D_Minor_op.70_IV-Finale
> >
> > Pas mal! Si Dvorak avait nommé son second mouvement Andante, alors ça
> > aurait marché. Ne me demande pas pourquoi, je viens de tester ça sur
> > ma machine (même version de sort), et j'ai pareil que toi. Si je
> > change Poco pour Andante, alors le tri est correct.
>
> C'est un « Poco adagio » (j'ai coupé toute la fin) ; avec « Adagio ma
> non troppo » ça irait aussi.
>
> En LC_ALL=C on retrouve le même désordre avec « sort -d », qui ignore
> les _- ... Est-ce que ce ne serait pas un bogue local de ce pu^Hcoquin
> de sort ?
À mon avis, probablement pas. D'après la page Info de coreutils :
(1) If you use a non-POSIX locale (e.g., by setting `LC_ALL' to
`en_US'), then `sort' may produce output that is sorted differently
than you're accustomed to. In that case, set the `LC_ALL' environment
variable to `C'. Note that setting only `LC_COLLATE' has two problems.
First, it is ineffective if `LC_ALL' is also set. Second, it has
undefined behavior if `LC_CTYPE' (or `LANG', if `LC_CTYPE' is unset) is
set to an incompatible value. For example, you get undefined behavior
if `LC_CTYPE' is `ja_JP.PCK' but `LC_COLLATE' is `en_US.UTF-8'.
En fait, avec une locale fr_FR, sort utilise les chaînes suivantes pour
faire les comparaisons :
...IAllegro...
...IIPoco...
...IIIScherzo...
...IVFinale...
(on peut s'en rendre compte en remplaçant le '-' par un 'A' par exemple).
"LC_ALL=C sort ..." ou "LC_COLLATE=C sort ..." fait ce qu'il semble
normal en incluant le caractere - dans sa comparaison.
Fred
--
Comment poser les questions de manière intelligente ?
http://www.gnurou.org/documents/smart-questions-fr.html
Comment signaler efficacement un bug ?
http://www.chiark.greenend.org.uk/~sgtatham/bugs-fr.html
Reply to: