cclass() — Return characters in a character class

Standards

Standards / Extensions C or C++ Dependencies
C Library both  

Format

#include <collate.h>

int cclass(char *class, collel_t **list);

General description

Finds all the collating elements of the class, class. The list is updated to point to the array of collating elements found. The list is valid until the next call to setlocale().

The function supports user-defined character classes. In C Library programs, the function also supports POSIX.2 character classes.

Returned value

If successful, cclass() returns the number of elements in the list pointed to by list.

If the first argument specifies a class that does not exist in the LC_CTYPE category of the current locale, cclass() returns -1.

Example

CELEBC02
⁄* CELEBC02  *⁄                                                                                                                  
#include <stdio.h>                                                              
#include <collate.h>                                                            
                                                                                
int main(void)                                                                  
{                                                                               
   collel_t *list;      ⁄* ptr to the digit class collation weights   *⁄        
   int       weights;   ⁄* no. of class collation class weights found *⁄        
   int       i;                                                                 
                                                                                
   weights = cclass("digit", &list);                                            
                                                                                
   printf("weights=%d\n", weights);                                             
   for (i=0; i<weights; i++)                                                    
      printf("*(list + %d) = %d\n", i, *(list  + i) );                          
}                                                                               

Related information