Case conversion
In many languages, alphabetic characters have an uppercase and lowercase representation. Your application must not assume the case equivalent for a particular character.
For example, it must not contain code such as the following to
obtain the uppercase equivalent of the character in
lower_char
:upper_char = lower_char - 'a' + 'A';
The preceding line works for the English characters of the ASCII code set. However, it does not work for 8-bit characters, such as à and .
To handle case conversion in your application, use functions in
the library
to obtain the case equivalent of a particular character. The following
table lists the case-conversion operations and the functions
that perform them, both the multibyte functions and their wide-character
equivalents.
Case-conversion operation | Multibyte-character function | Wide-character function |
---|---|---|
Obtain the lowercase equivalent of the source character | ifx_gl_tomlower() | ifx_gl_towlower() |
Obtain the uppercase equivalent of the source character | ifx_gl_tomupper() | ifx_gl_towupper() |
The case-conversion functions check the LC_CTYPE category of the current locale to determine the case equivalent of a source character. If the case equivalent that you want exists, the functions return an integer value that is the alphabetic case equivalent of the source character. If no case equivalent exists, these functions return the source character.
The following code fragment uses the ifx_gl_tomupper() function
to perform the case conversion of a multibyte character:
ret = ifx_gl_tomupper(upper_char, lower_char, char_sz)