The ifx_gl_wctomb() function

The ifx_gl_wctomb() function converts one wide character to its multibyte representation.

Syntax

#include <ifxgls.h>
...
int ifx_gl_wctomb(mb, wc)
       gl_mchar_t *mb;
       gl_wchar_t wc;
mb
A pointer to the multibyte character that contains the multibyte equivalent for wc.
wc
A pointer to the wide character to convert to the mb multibyte character.
Valid in client application Valid in DataBlade® UDR
Yes Yes

Usage

The ifx_gl_wctomb() function converts the wide character in wc to its multibyte representation and stores the result in consecutive bytes that start at mb. This function assumes that mb contains enough space to hold the multibyte representation of wc. You can use either of the following methods to determine the number of bytes that will be written to mb:
  • The function ifx_gl_mb_loc_max() calculates the maximum number of bytes in the multibyte representation for any wide character for the current locale.
  • The macro IFX_GL_MB_MAX is the maximum number of bytes in the multibyte representation for any wide character in any locale.

    The value is always greater than or equal to the value that ifx_gl_mb_loc_max() returns.

Of the two options, the macro IFX_GL_MB_MAX is faster and can initialize static buffers. The function ifx_gl_mb_loc_max() is slower but more precise.

Return values

>=0
The number of bytes written to mb.
-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 the following value.
IFX_GL_EILSEQ
The *wc value is not a valid wide character. In this case, some bytes might be written to mb, but the contents of mb are undefined.