The ifx_gl_mbsntslen() function

The ifx_gl_mbsntslen() function determines the number of characters in a multibyte string. It ignores trailing spaces.

Syntax

#include <ifxgls.h>
...
int ifx_gl_mbsntslen(mbs, mbs_byte_length)
       gl_mchar_t *mbs;
       int mbs_byte_length;
mbs
A pointer to the multibyte-character string whose length the function determines.
mbs_byte_length
The integer number of bytes in the mbs string. If mbs_byte_length is the value IFX_GL_NULL, the function assumes that mbs is a null-terminated string.
Valid in client application Valid in DataBlade® UDR
Yes Yes

Usage

The ifx_gl_mbsntslen() function returns the number of characters in mbs, not including any trailing-space characters. The trailing-space characters are all characters that the blank character class of the current locale defines. For more information about the blank class, see ids_gpg_037.html.

Space characters that are embedded in the string at any place except the end of the string are included in the count. For example, the following call to ifx_gl_mbsntslen() returns a value of 7 (the number of bytes in the string A1A2B1B2B3 cd E1, where A1A2 is the multibyte character of 2 bytes, B1B2B3 is the multibyte character of 3 bytes, and E1 is the multibyte character of 1 byte, and s represents a single-byte horizontal white space character):
ifx_gl_mbsntslen("A1A2B1B2B3scdsE1ssssss", mbs_byte_length)

Use the ifx_gl_mbslen() function if you want the length to include trailing white space.

Return values

>=0
The number of bytes in the mbs string, not including any trailing space.
-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
The mbs_byte_length is not equal to IFX_GL_NULL and is not greater than or equal to 0.
IFX_GL_EILSEQ
The *mbs value contains an invalid multibyte character.
IFX_GL_EINVAL
The function cannot determine whether the last character of mbs is a valid multibyte character because it would need to read more than mbs_byte_length bytes from mbs.