Standards / Extensions | C or C++ | Dependencies |
---|---|---|
Language Environment | both |
#include <collate.h>
char *colltostr(collel_t c);
Converts c to the string of the collating element. The colltostr() function is the inverse of strtocoll().
An application program can use the returned array from collrange() or collequiv(), calling ismccollel() on each element, only calling colltostr() if ismccollel() is true for the element. The string returned is valid until another call to setlocale().
If a value is passed representing a single character or a value that is not in range, colltostr() returns NULL.
⁄* CELEBC25
This example prints all the collating elements in the
collating sequence, using the &colltop. function to get the
string for the multi-character collating elements.
*⁄
#include <collate.h>
#include <locale.h>
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
main(int argc, char *argv[]) {
collel_t e, *rp;
int i;
setlocale(LC_ALL, "");
i = collorder(&rp);
for (; i-- > 0; rp++) {
if (ismccollel(*rp))
printf("'%s' ", colltostr(*rp));
else if (iswprint(*rp))
printf("'%lc' ", *rp);
else
printf("'%x' ", *rp);
}
}