The ifx_gl_wcsspn() function

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

Syntax

#include <ifxgls.h>
...
int ifx_gl_wcsspn(wcs1, wcs1_char_length, wcs2, wcs2_char_length)
       l_wchar_t *wcs1;
       int wcs1_char_length;
       gl_wchar_t *wcs2;
       int wcs2_char_length;
wcs1
A pointer to the wide-character string to check for a substring of characters found in wcs2.
wcs1_char_length
The integer number of characters in the wcs1 string. If wcs1_char_length is the value IFX_GL_NULL, the function assumes that wcs1 is a null-terminated string.
wcs2
A pointer to the wide-character string whose characters the function searches for in wcs1.
wcs2_char_length
The integer number of characters in the wcs2 string. If wcs2_char_length is the value IFX_GL_NULL, the function assumes that wcs2 is a null-terminated string.
Valid in client application Valid in DataBlade® UDR
Yes Yes

Usage

The ifx_gl_wcsspn() function returns the size of the initial substring of wcs1 that contains only characters that match characters in wcs2. The initial substring begins at the first character of wcs1. Therefore, this size is the number of characters in wcs1 before the first character that is not found in wcs2.

For example, suppose you have the following two wide-character strings, wcs1 and wcs2:
wcs1 = "A1A2B1B2C1C2D1D2A1A2E1E2F1F2A1A2G1G2D1D2";
wcs2 = "B1B2D1D2A1A2C1C2";
With these wide-character strings, the following call to the ifx_gl_wcsspn() function returns 5:
ifx_gl_wcsspn(wcs1, charlen1, wcs2, charlen2)

The first five characters of wcs1 are in wcs2. The sixth character in wcs1 is E1E2, which is not a character that matches one of the characters in wcs2.

Return values

>=0
The number of characters in the initial substring of wcs1 that consist entirely of wide characters in the string wcs2.
-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 wcs1_char_length is not equal to IFX_GL_NULL and is not greater than or equal to 0, or wcs2_char_length is not equal to IFX_GL_NULL and is not greater than or equal to 0.
IFX_GL_TERMMISMAT
Either wcs1_char_length is equal to IFX_GL_NULL, and wcs2_char_length is greater than or equal to 0; or wcs1_char_length is greater than or equal to 0, and wcs2_char_length is equal to IFX_GL_NULL.