Next: Elementary string functions with memory allocation, Previous: Elementary string conversions, Up: unistr.h
The following functions inspect and return details about the first character in a Unicode string.
Returns the length (number of units) of the first character in s, which is no longer than n. Returns 0 if it is the NUL character. Returns -1 upon failure.
This function is similar to
mblen, except that it operates on a Unicode string and that s must not be NULL.
Returns the length (number of units) of the first character in s, putting its
ucs4_trepresentation in*puc. Upon failure,*puc is set to0xfffd, and an appropriate number of units is returned.The number of available units, n, must be > 0.
This function is similar to
mbtowc, except that it operates on a Unicode string, puc and s must not be NULL, n must be > 0, and the NUL character is not treated specially.
This function is like
u8_mbtouc_unsafe, except that it will detect an invalid UTF-8 character, even if the library is compiled without --enable-safety.
Returns the length (number of units) of the first character in s, putting its
ucs4_trepresentation in*puc. Upon failure,*puc is set to0xfffd, and -1 is returned for an invalid sequence of units, -2 is returned for an incomplete sequence of units.The number of available units, n, must be > 0.
This function is similar to
u8_mbtouc, except that the return value gives more details about the failure, similar tombrtowc.
The following function stores a Unicode character as a Unicode string in memory.
Puts the multibyte character represented by uc in s, returning its length. Returns -1 upon failure, -2 if the number of available units, n, is too small. The latter case cannot occur if n >= 6/2/1, respectively.
This function is similar to
wctomb, except that it operates on a Unicode strings, s must not be NULL, and the argument n must be specified.
The following functions copy Unicode strings in memory.
Copies n units from src to dest.
This function is similar to
memcpy, except that it operates on Unicode strings.
Copies n units from src to dest, guaranteeing correct behavior for overlapping memory areas.
This function is similar to
memmove, except that it operates on Unicode strings.
The following function fills a Unicode string.
Sets the first n characters of s to uc. uc should be a character that occupies only 1 unit.
This function is similar to
memset, except that it operates on Unicode strings.
The following function compares two Unicode strings of the same length.
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.
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.
The following function searches for a given Unicode character.
Searches the string at s for uc. Returns a pointer to the first occurrence of uc in s, or NULL if uc does not occur in s.
This function is similar to
memchr, except that it operates on Unicode strings.
The following function counts the number of Unicode characters.
Counts and returns the number of Unicode characters in the n units from s.
This function is similar to the gnulib function
mbsnlen, except that it operates on Unicode strings.