What I want to do: sort words according to specific language rules (french,
german, spanish, etc.)
My problem: how can I specify the sorting rules so that I can use the library
function strcoll(3)?
A little history of my erratic wandering in the manuals: In SunOs 4.1.1 there
are library functions strcoll(3) and strxfrm(3) that can be used to sort
strings according to specific "national languages". After some searching
(there is no pointer in the man page), I discovered that there is a library
function setlocale(3V) that one can use with a parameter LC_COLLATE to set the
collating sequence; a description of a standard collating sequences can be
found in /usr/share/lib/locale/LC_COLLATE/default. Infortunately this is not
a text file and does not help on how to specify a different collating
sequence. Again there is no pointer on the man page to colldef(8) which I
eventually discovered; colldef(8) is supposed to describe how to specify a
collating sequence. But frankly it is a bit terse and I was not able to
understand what to do. There is also the man page locale(5) but of not much
help either.
I wasn't luckier when reading in the "System Services Overview" the section
about "Building a String Collation Table: colldef(8)". The example, is
really terse, and again there is no definition of the syntax to use for
specifying a collating sequence (meaning of parentheses, semicolon etc.)
Going back to the beginning of the chapter there is a reference to the "C"
environment, described in Volume 3 of the X/OPEN Programmer's Guide, Issue 2
(XPG2). The story ends here as this manual is not distributed with the Sun
documentation, and I don't know (yet) how to get a copy. So, apart from the
very poor cross referencing in Sun's manual pages, there is the more serious
problem that the Sun provided documentation is incomplete!
I would be grateful if you could provide me with some more information,
for example:
- a definition of the syntax to use for colldef
- where to get XPG2
- a complete definition of a collating sequence (standard,
french, german, spanish)
- alternative solutions (public domain package for sorting strings
according to a user specified order).
- comments on the practicality of strcoll (eg. fast/slow) and colldef
(what can't you do with it).
- description of the algorithm used by strcoll.
Thanks in advance!
Dominique
--
ISSCO, University of Geneva | X400: S=petitp;OU=divsun;O=unige;
54 route des Acacias | PRMD=switch;ADMD=arcom;C=ch
CH-1227 GENEVA (Switzerland) | UUCP: mcvax!cui!divsun.unige.ch!petitp
Tel: +41/22/705 71 17 | FAX: +41/22/300 10 86