The ifx_gl_mbsspn() function

The ifx_gl_mbsspn() function determines the length of a multibyte substring for a specified multibyte-character string.

Syntax

#include <ifxgls.h>
...
int ifx_gl_mbsspn(mbs1, mbs1_byte_length, mbs2, mbs2_byte_length)
       gl_mchar_t *mbs1;
       int mbs1_byte_length;
       gl_mchar_t *mbs2;
       int mbs2_byte_length;
mbs1
A pointer to the multibyte string to check for a substring of characters found in mbs2.
mbs1_byte_length
The integer number of bytes in the mbs1 string. If mbs1_byte_length is the value IFX_GL_NULL, the function assumes that mbs1 is a null-terminated string.
mbs2
A pointer to the multibyte-character string whose characters the function searches for in mbs1.
mbs2_byte_length
The integer number of bytes in the mbs2 string. If mbs2_byte_length is the value IFX_GL_NULL, the function assumes that mbs2 is a null-terminated string.
Valid in client application Valid in DataBlade® UDR
Yes Yes

Usage

The ifx_gl_mbsspn() function returns the size of the initial substring of mbs1 that contains only characters that match characters in mbs2. The initial substring begins at the first character of mbs1. Therefore, this size is the number of characters in mbs1 before the first character that is not found in mbs2. For example, suppose you have the following two multibyte-characters strings, mbs1 and mbs2. For example, suppose you have the following two multibyte-characters strings, mbs1 and mbs2:
mbs1 = "A1A2B1B2B3C1C2D1D2D3A1A2E1F1F2A1A2G1D1D2D3";
mbs2 = "B1B2B3D1D2D3A1A2C2C2";
With these multibyte strings, the following call to the ifx_gl_mbsspn() function returns 5:
ifx_gl_mbsspn(mbs1, bytelen1, mbs2, bytelen2)

The first five characters of mbs1 are in mbs2. The sixth character in mbs1 is E1, which is not a character that matches one of the characters in mbs2.

Return values

>=0
The number of characters in mbs1 before the first character for which mbs1 and mbs2 differ.
-1
The function was not successful, and the error number is set to indicate the cause. See the Errors section.

Errors

If an error occurred, this function returns -1 and sets the ifx_gl_lc_errno() error number to one of the following values.
IFX_GL_PARAMERR
Either mbs1_byte_length is not equal to IFX_GL_NULL and is not greater than or equal to 0, or mbs2_byte_length is not equal to IFX_GL_NULL and is not greater than or equal to 0.
IFX_GL_TERMMISMAT
Either mbs1_byte_length is equal to IFX_GL_NULL, and mbs2_byte_length is greater than or equal to 0; or mbs1_byte_length is greater than or equal to 0, and mbs2_byte_length is equal to IFX_GL_NULL.
IFX_GL_EILSEQ
Either mbs1 or mbs2 contains an invalid multibyte character.
IFX_GL_EINVAL
Either the function cannot determine whether the last character of mbs1 is a valid multibyte character because it would need to read more than mbs1_byte_length bytes from mbs1, or the function cannot determine whether the last character of mbs2 is a valid multibyte character because it would need to read more than mbs2_byte_length bytes from mbs2.