The ifx_gl_mbsncpy() function

The ifx_gl_mbsncpy() function copies a specified number of multibyte characters from a multibyte-character string.

Syntax

#include <ifxgls.h>
...
int ifx_gl_mbsncpy(mbs1, mbs2, mbs2_byte_length, char_limit)
       gl_mchar_t *mbs1;
       gl_mchar_t *mbs2;
       int mbs2_byte_length;
       int char_limit;
mbs1
A pointer to the location where the function copies mbs2.
mbs2
A pointer to the multibyte-character string to copy to 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.
char_limit
The maximum number of multibyte characters to read from mbs2.
Valid in client application Valid in DataBlade® UDR
Yes Yes

Usage

The ifx_gl_mbsncpy() function copies mbs2 to the location that mbs1 references. The function reads no more than char_limit characters from mbs2 and writes them to mbs1. If mbs1 and mbs2 overlap, the results of this function are undefined.

If mbs1 and mbs2 overlap, the results of this function are undefined. If mbs2_byte_length is equal to IFX_GL_NULL, the function null-terminates the concatenated string. Any other value of mbs2_byte_length means that the function does not null-terminate the resulting concatenated string.

Return values

>=0
The number of bytes in the copied string, not including any null terminator.
-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 mbs2_byte_length is not equal to IFX_GL_NULL and is not greater than or equal to 0.
IFX_GL_EILSEQ
The *mbs2 value contains an invalid multibyte character.
IFX_GL_EINVAL
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.