String Traversal Because a single-byte character occupies only one byte, string traversal of a single-byte character string can use the C compiler built-in scaling. However, you must take special steps to handle string traversal of multibyte-character and wide-character strings. Multibyte-Character-String Traversal Because a multibyte-character string might contain multibyte characters of different sizes, you cannot automatically traverse the string with any built-in scaling. Instead, use the following functions in INFORMIX-GLS to traverse a multibyte string:
Append a copy of one character string to the end of another character string. If the two strings overlap, the result of the operation is undefined.
ifx_gl_mbscat()
ifx_gl_wcscat()
Append a specified number of characters from one character string to the end of a second character string. If the two strings overlap, the result of this operation is undefined.
ifx_gl_mbsncat()
ifx_gl_wcsncat()
String Copying The following table lists the INFORMIX-GLS multibyte functions and their wide-character equivalents that perform string copying.
Copy one character string to a specified location in a second character string. If the two strings overlap, the result of this operation is undefined.
ifx_gl_mbscpy()
ifx_gl_wcscpy()
Copy a specified number of characters from one character string to a second character string. If the two strings overlap, the result of this operation is undefined.
ifx_gl_mbsncpy()
ifx_gl_wcsncpy()
String-Length Determination The following table lists the INFORMIX-GLS multibyte functions and their wide-character equivalents that determine string length or number of characters.
(1 of 2)
Determine the number of characters in the string, not including any terminating null characters.
ifx_gl_mbslen()
ifx_gl_wcslen()
Determine the number of bytes in a multibyte string, not including any trailing space characters.
ifx_gl_mbsntsbytes()
None
Determine the number of characters in a string, not including the trailing space characters.
ifx_gl_mbsntslen()
ifx_gl_wcsntslen()
Determine the number of characters in the initial substring of one string that consists entirely of characters in a second specified character string.
ifx_gl_mbsspn()
ifx_gl_wcsspn()
Determine the number of characters in the initial substring of one string that consists entirely of characters not in a specified second character string.
ifx_gl_mbscspn()
ifx_gl_wcscspn()
Character Searching The following table lists the INFORMIX-GLS multibyte functions and their wide-character equivalents that perform character searching.
Search for the first occurrence of a character in the character string.
ifx_gl_mbschr()
ifx_gl_wcschr()
Search for the last occurrence of a character in the character string.
ifx_gl_mbsrchr()
ifx_gl_wcsrchr()
Search for a substring in another string.
ifx_gl_mbsmbs()
ifx_gl_wcswcs()
Search for the first occurrence in the character string of any character from a second specified character string.
ifx_gl_mbspbrk()
ifx_gl_wcspbrk()
Character/String Comparison and Sorting Collation involves the sorting of character data that is either stored in a database or manipulated in a client application. Informix database servers support the following methods of collation for character data:
a
A
Apple
apple
À
B
ÀB
AC
BD
Compare two character strings by localized collation order.
ifx_gl_mbscoll()
ifx_gl_wcscoll()
These functions access the LC_COLLATE category of a locale file to obtain localized collating information when they compare character strings. They return an integer value that indicates the results of the comparison between two string arguments. The following table shows the comparison between the first string argument (Arg 1) and the second string argument (Arg 2), as well as the return values.
Arg 1 < Arg 2
<0
Arg 1 = Arg 2
0
Arg 1 > Arg 2
>0
The ifx_gl_mbscoll() and ifx_gl_wcscoll() functions do not return a special value if an error has occurred. Therefore, to detect an error condition, you must initialize the ifx_gl_lc_errno() error number to zero before you call one of these functions and check ifx_gl_lc_errno() after you call the function. The following code fragment performs error checking for a call to the ifx_gl_wcscoll() function: