colltostr() — Return a string for a collating element
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
Language Environment | both |
Format
#include <collate.h>
char *colltostr(collel_t c);
General description
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().
Returned value
If a value is passed representing a single character or a value that is not in range, colltostr() returns NULL.
Example
CELEBC25
/* 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);
}
}
Related information
- collate.h
- cclass() — Return characters in a character class
- collequiv() — Return a list of equivalent collating elements
- collorder() — Return list of collating elements
- collrange() — Calculate the range list of collating elements
- getmccoll() — Get next collating element from string
- getwmccoll() — Get next collating element from wide string
- ismccollel() — Identify a multicharacter collating element
- maxcoll() — Return maximum collating element
- strtocoll() — Return collating element for string