Mstdlib-1.24.0
Case Folding

Functions

M_utf8_error_t M_utf8_toupper_cp (M_uint32 cp, M_uint32 *upper_cp)
 
M_utf8_error_t M_utf8_toupper_chr (const char *str, char *buf, size_t buf_size, size_t *len, const char **next)
 
M_utf8_error_t M_utf8_toupper_chr_buf (const char *str, M_buf_t *buf, const char **next)
 
M_utf8_error_t M_utf8_toupper (const char *str, char **out)
 
M_utf8_error_t M_utf8_toupper_buf (const char *str, M_buf_t *buf)
 
M_utf8_error_t M_utf8_tolower_cp (M_uint32 cp, M_uint32 *lower_cp)
 
M_utf8_error_t M_utf8_tolower_chr (const char *str, char *buf, size_t buf_size, size_t *len, const char **next)
 
M_utf8_error_t M_utf8_tolower_chr_buf (const char *str, M_buf_t *buf, const char **next)
 
M_utf8_error_t M_utf8_tolower (const char *str, char **out)
 
M_utf8_error_t M_utf8_tolower_buf (const char *str, M_buf_t *buf)
 
M_utf8_error_t M_utf8_totitle_cp (M_uint32 cp, M_uint32 *title_cp)
 
M_utf8_error_t M_utf8_totitle_chr (const char *str, char *buf, size_t buf_size, size_t *len, const char **next)
 
M_utf8_error_t M_utf8_totitle_chr_buf (const char *str, M_buf_t *buf, const char **next)
 
M_utf8_error_t M_utf8_totitle (const char *str, char **out)
 
M_utf8_error_t M_utf8_totitle_buf (const char *str, M_buf_t *buf)
 

Detailed Description

The case folding as defined by the official UTF-8 mapping is utalized. UTF-8 does not have a one to one mapping for case folding. Multiple codes can fold to the same code point. Coversion to upper, then to lower, then back to upper can result in a different upper case string than the original input.

For example, 0x004B (capital K) maps to 0x006B (lower k). 0x212A (kelvin sign) also maps to 0x006B. 0x006B maps to 0x004B. So converting 0x212A to lower then back to upper will output 0x004B.

Note
Not all characters have a case equivalent. These characters will return themselves when folded.

Function Documentation

◆ M_utf8_toupper_cp()

M_utf8_error_t M_utf8_toupper_cp ( M_uint32  cp,
M_uint32 *  upper_cp 
)

Convert a code point to the equivalent upper case code point.

Parameters
[in]cpCode point to convert.
[out]upper_cpEquivalent upper case code point. Or cp if there is no equivalent.
Returns
Result.

◆ M_utf8_toupper_chr()

M_utf8_error_t M_utf8_toupper_chr ( const char *  str,
char *  buf,
size_t  buf_size,
size_t *  len,
const char **  next 
)

Read a utf-8 sequence converting to upper case.

Output is not NULL terminated.

Parameters
[in]strutf-8 string.
[in]bufBuffer to put utf-8 sequence. Can be NULL.
[in]buf_sizeSize of the buffer.
[out]lenLength of the sequence that was put into buffer.
[out]nextStart of next character. Will point to NULL terminator if last character.
Returns
Result.

◆ M_utf8_toupper_chr_buf()

M_utf8_error_t M_utf8_toupper_chr_buf ( const char *  str,
M_buf_t buf,
const char **  next 
)

Read a utf-8 sequence into an M_buf_t converting to upper case.

Parameters
[in]strutf-8 string.
[in]bufBuffer to put upper case utf-8 sequence.
[out]nextStart of next character. Will point to NULL terminator if last character.
Returns
Result.

◆ M_utf8_toupper()

M_utf8_error_t M_utf8_toupper ( const char *  str,
char **  out 
)

Convert a utf-8 string to an upper case equivalent string.

Parameters
[in]strutf-8 string.
[out]outUpper case utf-8 string.
Returns
Result.

◆ M_utf8_toupper_buf()

M_utf8_error_t M_utf8_toupper_buf ( const char *  str,
M_buf_t buf 
)

Read a utf-8 string into an M_buf_t converting to upper case.

Parameters
[in]strutf-8 string.
[in]bufBuffer to put upper case utf-8 string.
Returns
Result.

◆ M_utf8_tolower_cp()

M_utf8_error_t M_utf8_tolower_cp ( M_uint32  cp,
M_uint32 *  lower_cp 
)

Convert a code point to the equivalent loer case code point.

Parameters
[in]cpCode point to convert.
[out]lower_cpEquivalent lower case code point. Or cp if there is no equivalent.
Returns
Result.

◆ M_utf8_tolower_chr()

M_utf8_error_t M_utf8_tolower_chr ( const char *  str,
char *  buf,
size_t  buf_size,
size_t *  len,
const char **  next 
)

Read a utf-8 sequence converting to lower case.

Output is not NULL terminated.

Parameters
[in]strutf-8 string.
[in]bufBuffer to put utf-8 sequence. Can be NULL.
[in]buf_sizeSize of the buffer.
[out]lenLength of the sequence that was put into buffer.
[out]nextStart of next character. Will point to NULL terminator if last character.
Returns
Result.

◆ M_utf8_tolower_chr_buf()

M_utf8_error_t M_utf8_tolower_chr_buf ( const char *  str,
M_buf_t buf,
const char **  next 
)

Read a utf-8 sequence into an M_buf_t converting to lower case.

Parameters
[in]strutf-8 string.
[in]bufBuffer to put lower case utf-8 sequence.
[out]nextStart of next character. Will point to NULL terminator if last character.
Returns
Result.

◆ M_utf8_tolower()

M_utf8_error_t M_utf8_tolower ( const char *  str,
char **  out 
)

Convert a utf-8 string to an lower case equivalent string.

Parameters
[in]strutf-8 string.
[out]outLower case utf-8 string.
Returns
Result.

◆ M_utf8_tolower_buf()

M_utf8_error_t M_utf8_tolower_buf ( const char *  str,
M_buf_t buf 
)

Read a utf-8 string into an M_buf_t converting to lower case.

Parameters
[in]strutf-8 string.
[in]bufBuffer to put lower case utf-8 string.
Returns
Result.

◆ M_utf8_totitle_cp()

M_utf8_error_t M_utf8_totitle_cp ( M_uint32  cp,
M_uint32 *  title_cp 
)

Convert a code point to the equivalent title case code point.

Parameters
[in]cpCode point to convert.
[out]title_cpEquivalent title case code point. Or cp if there is no equivalent.
Returns
Result.

◆ M_utf8_totitle_chr()

M_utf8_error_t M_utf8_totitle_chr ( const char *  str,
char *  buf,
size_t  buf_size,
size_t *  len,
const char **  next 
)

Read a utf-8 sequence converting to title case.

Output is not NULL terminated.

Parameters
[in]strutf-8 string.
[in]bufBuffer to put utf-8 sequence. Can be NULL.
[in]buf_sizeSize of the buffer.
[out]lenLength of the sequence that was put into buffer.
[out]nextStart of next character. Will point to NULL terminator if last character.
Returns
Result.

◆ M_utf8_totitle_chr_buf()

M_utf8_error_t M_utf8_totitle_chr_buf ( const char *  str,
M_buf_t buf,
const char **  next 
)

Read a utf-8 sequence into an M_buf_t converting to title case.

Parameters
[in]strutf-8 string.
[in]bufBuffer to put title case utf-8 sequence.
[out]nextStart of next character. Will point to NULL terminator if last character.
Returns
Result.

◆ M_utf8_totitle()

M_utf8_error_t M_utf8_totitle ( const char *  str,
char **  out 
)

Convert a utf-8 string to an title case equivalent string.

Parameters
[in]strutf-8 string.
[out]outLower case utf-8 string.
Returns
Result.

◆ M_utf8_totitle_buf()

M_utf8_error_t M_utf8_totitle_buf ( const char *  str,
M_buf_t buf 
)

Read a utf-8 string into an M_buf_t converting to title case.

Parameters
[in]strutf-8 string.
[in]bufBuffer to put title case utf-8 string.
Returns
Result.