Standards / Extensions | C or C++ | Dependencies |
---|---|---|
Language Environment | both |
#include <collate.h>
int collequiv(collel_t c, collel_t **list);
Finds all the collating elements whose primary weight is the same as the primary weight of c. It then updates the list to point to the first element of the array in which all the found elements are stored. The list of elements is valid until the next call to setlocale(), with categories LC_ALL, LC_COLLATE, or LC_CTYPE.
Another call to collequiv() may override the current list.
For information about the effect of setlocale() and locale.h, see “Internationalization: Locales and Character Sets” in z/OS XL C/C++ Programming Guide.
If successful, collequiv() returns the number of collating elements found.
If the value of c is not in the valid range of collating elements in the current locale, collequiv() returns -1.
⁄* CELEBC22
This example prints the collating elements that have an
equivalent weight as the collating element passed in
argv[1].
*⁄
#include "stdio.h"
#include "locale.h"
#include "collate.h"
#include "stdlib.h"
#include "wctype.h"
#include "wchar.h"
main(int argc, char *argv[]) {
collel_t e, *rp;
int i;
setlocale(LC_ALL, "");
if ((e = strtocoll(argv[1])) == (collel_t)-1) {
printf("'%s' collating element not defined\n", argv[1]);
exit(1);
}
if ((i = collequiv(e, &rp)) == -1) {
printf("Invalid collating element '%s'\n", argv[1]);
exit(1);
}
for (; i-- > 0; rp++) {
if (ismccollel(*rp))
printf("'%s' ", colltostr(*rp));
else if (iswprint(*rp))
printf("'%lc' ", *rp);
else
printf("'%x' ", *rp);
}
}