The ifx_gl_getmb() function
The ifx_gl_getmb() function obtains a single multibyte character from a user-specified location.
Syntax
#include <ifxgls.h>
...
int ifx_gl_fgetmb(mb, funcp, v, bytes_got)
gl_mchar_t *mb;
int (*funcp)(void *v);
void *v;
int *bytes_got;
- mb
- A pointer to the multibyte character whose bytes the funcp function reads from a specified location.
- funcp
- A pointer to a function that you define to specify the location from which to read the multibyte character.
- v
- A pointer that the ifx_gl_getmb() function passes to the funcp function each time that it is called.
- bytes_got
- A pointer to an integer that ifx_gl_getmb() sets to indicate the number of bytes that the funcp function has successfully read.
Valid in client application | Valid in DataBlade® UDR |
---|---|
Yes | Yes |
Usage
The ifx_gl_getmb() function calls a function that you define to obtain the bytes that form one multibyte character from a specified location. This multibyte character is then written to the mb buffer.
int funcp(void *v)
The pointer v is passed to funcp each time that it is called. On success, funcp must return a value 0 - 255, inclusive, which is the next byte of the multibyte character. On failure, funcp must return -1.
- A complete multibyte character has been formed.
- The funcp function returns a byte that forms an illegal character when appended to the bytes already read.
- The funcp function fails.
- The function ifx_gl_mb_loc_max() calculates the maximum number of bytes in any multibyte character for the current locale.
- The macro IFX_GL_MB_MAX is the maximum number of bytes in any multibyte character in any locale. This value is always equal to or greater than the value that ifx_gl_mb_loc_max() returns.
Of these two options, the macro IFX_GL_MB_MAX is faster, and it can be used to initialize static buffers. The function ifx_gl_mb_loc_max() is slower but more precise.
The number of bytes that funcp successfully reads is returned in bytes_got (even when funcp fails).
Return values
- 0 - 255
- The value of the next byte for the multibyte character
- -1
- The function was not successful, and the error number is set to indicate the cause. See the Errors section.
Errors
- IFX_GL_EILSEQ
- The bytes read from funcp do not form a valid multibyte character.
- IFX_GL_EINVAL
- The funcp function returned -1 in the middle of an otherwise valid multibyte character.
- IFX_GL_EOF
- The funcp function returned -1 on the first call.