# strcoll

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           strcoll, strcoll_l — string comparison using collating information
    


## SYNOPSIS



           #include <string.h>
    
           int strcoll(const char *_s1_ , const char *_s2_);
           int strcoll_l(const char *_s1_ , const char *_s2_ ,
               locale_t _locale_);
    


## DESCRIPTION



           For _strcoll_(): The functionality described on this reference page
           is aligned with the ISO C standard. Any conflict between the
           requirements described here and the ISO C standard is
           unintentional. This volume of POSIX.1‐2017 defers to the ISO C
           standard.
    
           The _strcoll_() and _strcoll_l_() functions shall compare the string
           pointed to by _s1_ to the string pointed to by _s2_ , both interpreted
           as appropriate to the _LC_COLLATE_ category of the current locale,
           or of the locale represented by _locale_ , respectively.
    
           The _strcoll_() and _strcoll_l_() functions shall not change the
           setting of _errno_ if successful.
    
           Since no return value is reserved to indicate an error, an
           application wishing to check for error situations should set _errno_
           to 0, then call _strcoll_(), or _strcoll_l_() then check _errno_.
    
           The behavior is undefined if the _locale_ argument to _strcoll_l_() is
           the special locale object LC_GLOBAL_LOCALE or is not a valid
           locale object handle.
    


## RETURN VALUE



           Upon successful completion, _strcoll_() shall return an integer
           greater than, equal to, or less than 0, according to whether the
           string pointed to by _s1_ is greater than, equal to, or less than
           the string pointed to by _s2_ when both are interpreted as
           appropriate to the current locale.  On error, _strcoll_() may set
           _errno_ , but no return value is reserved to indicate an error.
    
           Upon successful completion, _strcoll_l_() shall return an integer
           greater than, equal to, or less than 0, according to whether the
           string pointed to by _s1_ is greater than, equal to, or less than
           the string pointed to by _s2_ when both are interpreted as
           appropriate to the locale represented by _locale_.  On error,
           _strcoll_l_() may set _errno_ , but no return value is reserved to
           indicate an error.
    


## ERRORS



           These functions may fail if:
    
           **EINVAL** The _s1_ or _s2_ arguments contain characters outside the
                  domain of the collating sequence.
    
           _The following sections are informative._
    


## EXAMPLES



       **Comparing Nodes**
           The following example uses an application-defined function,
           _node_compare_(), to compare two nodes based on an alphabetical
           ordering of the _string_ field.
    
               #include <string.h>
               ...
               struct node { /* These are stored in the table. */
                   char *string;
                   int length;
               };
               ...
               int node_compare(const void *node1, const void *node2)
               {
                   return strcoll(((const struct node *)node1)->string,
                       ((const struct node *)node2)->string);
               }
               ...
    


## APPLICATION USAGE



           The _strxfrm_() and _strcmp_() functions should be used for sorting
           large lists.
    


## RATIONALE



           None.
    


## FUTURE DIRECTIONS



           None.
    


* * *