Next: , Previous: , Up: Elementary string functions on NUL terminated strings   [Contents][Index]


4.5.4 Comparing NUL terminated Unicode strings

The following functions compare two Unicode strings. They ignore locale-dependent collation rules.

Function: int u8_strcmp (const uint8_t *s1, const uint8_t *s2)
Function: int u16_strcmp (const uint16_t *s1, const uint16_t *s2)
Function: int u32_strcmp (const uint32_t *s1, const uint32_t *s2)

Compares s1 and s2, lexicographically. Returns a negative value if s1 compares smaller than s2, a positive value if s1 compares larger than s2, or 0 if they compare equal.

This function is similar to strcmp and wcscmp, except that it operates on Unicode strings.

Function: int u8_strcoll (const uint8_t *s1, const uint8_t *s2)
Function: int u16_strcoll (const uint16_t *s1, const uint16_t *s2)
Function: int u32_strcoll (const uint32_t *s1, const uint32_t *s2)

Compares s1 and s2 using the collation rules of the current locale. Returns -1 if s1 < s2, 0 if s1 = s2, 1 if s1 > s2. Upon failure, sets errno and returns any value.

This function is similar to strcoll and wcscoll, except that it operates on Unicode strings.

Note that this function may consider different canonical normalizations of the same string as having a large distance. It is therefore better to use the function u8_normcoll instead of this one; see Normalization forms (composition and decomposition) <uninorm.h>.

Function: int u8_strncmp (const uint8_t *s1, const uint8_t *s2, size_t n)
Function: int u16_strncmp (const uint16_t *s1, const uint16_t *s2, size_t n)
Function: int u32_strncmp (const uint32_t *s1, const uint32_t *s2, size_t n)

Compares no more than n units of s1 and s2.

This function is similar to strncmp and wcsncmp, except that it operates on Unicode strings.


Next: Duplicating a NUL terminated Unicode string, Previous: Copying a NUL terminated Unicode string, Up: Elementary string functions on NUL terminated strings   [Contents][Index]