Next: , Previous: , Up: Elementary string functions   [Contents][Index]


4.3.4 Comparing Unicode strings

The following function compares two Unicode strings of the same length.

Function: int u8_cmp (const uint8_t *s1, const uint8_t *s2, size_t n)
Function: int u16_cmp (const uint16_t *s1, const uint16_t *s2, size_t n)
Function: int u32_cmp (const uint32_t *s1, const uint32_t *s2, size_t n)

Compares s1 and s2, each of length n, 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 memcmp, except that it operates on Unicode strings.

The following function compares two Unicode strings of possibly different lengths.

Function: int u8_cmp2 (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2)
Function: int u16_cmp2 (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2)
Function: int u32_cmp2 (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2)

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 the gnulib function memcmp2, except that it operates on Unicode strings.