Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

mbsrtowcs()

Convert a multibyte-character string into a wide-character string (restartable)

Synopsis:

#include <wchar.h>

size_t mbsrtowcs( wchar_t * dst, 
                  const char ** src,
                  size_t n, 
                  mbstate_t * ps );

Arguments:

dst
A pointer to a buffer where the function can store the wide-character string.
src
The string of multibyte characters that you want to convert.
n
The maximum number of bytes that you want to convert.
ps
An internal pointer that lets mbsrtowcs() be a restartable version of mbstowcs(); if ps is NULL, mbsrtowcs() uses its own internal variable.

You can call mbsinit() to determine the status of this variable.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The mbsrtowcs() function converts a string of multibyte characters pointed to by src into the corresponding wide characters pointed to by dst, to a maximum of n bytes, including the terminating NULL character.

The function converts each character as if by a call to mbtowc() and stops early if:

Or:

This function is affected by LC_TYPE.

Returns:

(size_t)-1
Failure; invalid wide-character code.
x
Success; the number of total bytes successfully converted, not including the terminating NULL byte.

Errors:

EILSEQ
Invalid character sequence.
EINVAL
The ps argument points to an invalid object.

Classification:

ANSI, POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno

"Multibyte character functions" and "Wide-character functions" in the summary of functions chapter.