Next: , Previous: Case mappings of strings, Up: unicase.h


13.3 Case mappings of substrings

Case mapping of a substring cannot simply be performed by extracting the substring and then applying the case mapping function to it. This does not work because case mapping requires some information about the surrounding characters. The following functions allow to apply case mappings to substrings of a given string, while taking into account the characters that precede it (the “prefix”) and the characters that follow it (the “suffix”).

— Type: casing_prefix_context_t

This data type denotes the case-mapping context that is given by a prefix string. It is an immediate type that can be copied by simple assignment, without involving memory allocation. It is not an array type.

— Constant: casing_prefix_context_t unicase_empty_prefix_context

This constant is the case-mapping context that corresponds to an empty prefix string.

The following functions return casing_prefix_context_t objects:

— Function: casing_prefix_context_t u8_casing_prefix_context (const uint8_t *s, size_t n)
— Function: casing_prefix_context_t u16_casing_prefix_context (const uint16_t *s, size_t n)
— Function: casing_prefix_context_t u32_casing_prefix_context (const uint32_t *s, size_t n)

Returns the case-mapping context of a given prefix string.

— Function: casing_prefix_context_t u8_casing_prefixes_context (const uint8_t *s, size_t n, casing_prefix_context_t a_context)
— Function: casing_prefix_context_t u16_casing_prefixes_context (const uint16_t *s, size_t n, casing_prefix_context_t a_context)
— Function: casing_prefix_context_t u32_casing_prefixes_context (const uint32_t *s, size_t n, casing_prefix_context_t a_context)

Returns the case-mapping context of the prefix concat(a, s), given the case-mapping context of the prefix a.

— Type: casing_suffix_context_t

This data type denotes the case-mapping context that is given by a suffix string. It is an immediate type that can be copied by simple assignment, without involving memory allocation. It is not an array type.

— Constant: casing_suffix_context_t unicase_empty_suffix_context

This constant is the case-mapping context that corresponds to an empty suffix string.

The following functions return casing_suffix_context_t objects:

— Function: casing_suffix_context_t u8_casing_suffix_context (const uint8_t *s, size_t n)
— Function: casing_suffix_context_t u16_casing_suffix_context (const uint16_t *s, size_t n)
— Function: casing_suffix_context_t u32_casing_suffix_context (const uint32_t *s, size_t n)

Returns the case-mapping context of a given suffix string.

— Function: casing_suffix_context_t u8_casing_suffixes_context (const uint8_t *s, size_t n, casing_suffix_context_t a_context)
— Function: casing_suffix_context_t u16_casing_suffixes_context (const uint16_t *s, size_t n, casing_suffix_context_t a_context)
— Function: casing_suffix_context_t u32_casing_suffixes_context (const uint32_t *s, size_t n, casing_suffix_context_t a_context)

Returns the case-mapping context of the suffix concat(s, a), given the case-mapping context of the suffix a.

The following functions perform a case mapping, considering the prefix context and the suffix context.

— Function: uint8_t * u8_ct_toupper (const uint8_t *s, size_t n, casing_prefix_context_t prefix_context, casing_suffix_context_t suffix_context, const char *iso639_language, uninorm_t nf, uint8_t *resultbuf, size_t *lengthp)
— Function: uint16_t * u16_ct_toupper (const uint16_t *s, size_t n, casing_prefix_context_t prefix_context, casing_suffix_context_t suffix_context, const char *iso639_language, uninorm_t nf, uint16_t *resultbuf, size_t *lengthp)
— Function: uint32_t * u32_ct_toupper (const uint32_t *s, size_t n, casing_prefix_context_t prefix_context, casing_suffix_context_t suffix_context, const char *iso639_language, uninorm_t nf, uint32_t *resultbuf, size_t *lengthp)

Returns the uppercase mapping of a string that is surrounded by a prefix and a suffix.

— Function: uint8_t * u8_ct_tolower (const uint8_t *s, size_t n, casing_prefix_context_t prefix_context, casing_suffix_context_t suffix_context, const char *iso639_language, uninorm_t nf, uint8_t *resultbuf, size_t *lengthp)
— Function: uint16_t * u16_ct_tolower (const uint16_t *s, size_t n, casing_prefix_context_t prefix_context, casing_suffix_context_t suffix_context, const char *iso639_language, uninorm_t nf, uint16_t *resultbuf, size_t *lengthp)
— Function: uint32_t * u32_ct_tolower (const uint32_t *s, size_t n, casing_prefix_context_t prefix_context, casing_suffix_context_t suffix_context, const char *iso639_language, uninorm_t nf, uint32_t *resultbuf, size_t *lengthp)

Returns the lowercase mapping of a string that is surrounded by a prefix and a suffix.

— Function: uint8_t * u8_ct_totitle (const uint8_t *s, size_t n, casing_prefix_context_t prefix_context, casing_suffix_context_t suffix_context, const char *iso639_language, uninorm_t nf, uint8_t *resultbuf, size_t *lengthp)
— Function: uint16_t * u16_ct_totitle (const uint16_t *s, size_t n, casing_prefix_context_t prefix_context, casing_suffix_context_t suffix_context, const char *iso639_language, uninorm_t nf, uint16_t *resultbuf, size_t *lengthp)
— Function: uint32_t * u32_ct_totitle (const uint32_t *s, size_t n, casing_prefix_context_t prefix_context, casing_suffix_context_t suffix_context, const char *iso639_language, uninorm_t nf, uint32_t *resultbuf, size_t *lengthp)

Returns the titlecase mapping of a string that is surrounded by a prefix and a suffix.

For example, to uppercase the UTF-8 substring between s + start_index and s + end_index of a string that extends from s to s + u8_strlen (s), you can use the statements

     size_t result_length;
     uint8_t result =
       u8_ct_toupper (s + start_index, end_index - start_index,
                      u8_casing_prefix_context (s, start_index),
                      u8_casing_suffix_context (s + end_index,
                                                u8_strlen (s) - end_index),
                      iso639_language, NULL, NULL, &result_length);