The ifx_gl_mblen() function
The ifx_gl_mblen() function returns the number of bytes in a multibyte character.
Syntax
#include <ifxgls.h>
...
int ifx_gl_mblen(mb, mb_byte_limit)
gl_mchar_t *mb;
int mb_byte_limit;
- mb
- A pointer to the multibyte character whose character classification you want to determine.
- mb_byte_limit
- The integer number of bytes to read from mb to try to form a complete multibyte character. If mb_byte_limit is IFX_GL_NO_LIMIT, the function reads as many bytes as necessary from mb to form a complete character.
Valid in client application | Valid in DataBlade® UDR |
---|---|
Yes | Yes |
Usage
The ifx_gl_mblen() function
determines the number of bytes in the multibyte character, mb.
This function is often used to advance a pointer through a null-terminated
multibyte string. However, it is slightly faster to advance a pointer
through a null-terminated string with ifx_gl_mbsnext(),
as the following code shows:
for ( mb = mbs; *mb != '\0'; )
{
if ( (mb = ifx_gl_mbsnext(mb, IFX_GL_NO_LIMIT)) == NULL )
/* handle error */
}
Return values
- >=0
- The number of bytes in the mb multibyte character.
- -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_EILSEQ
- The *mb value is not a valid multibyte character.
- IFX_GL_EINVAL
- The function cannot determine whether mb is a valid multibyte character because it would need to read more than mb_byte_limit bytes from mb. If mb_byte_limit is less than or equal to 0, this function always returns this error.