mbsrtowcs(), mbsnrtowcs(), mbsrtowcs_l(), mbsnrtowcs_l()

convert multibyte character string to wide characters 

Function


SYNOPSIS

#include <wchar.h>

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

size_t mbsnrtowcs(wchar_t *dst, const char **src, size_t nms, size_t len, mbstate_t *ps);

#include <wchar.h>

#include <locale.h>

size_t mbsrtowcs_l(wchar_t *dst, const char **src, size_t len, mbstate_t *ps, locale_t locale);

size_t mbsnrtowcs_l(wchar_t *dst, const char **src, size_t nms, size_t len, mbstate_t *ps, locale_t locale);


DESCRIPTION

The mbsrtowcs() function converts a sequence of characters, beginning in the specified conversion state, from the array indirectly pointed to by src into a sequence of corresponding wide characters. If dst is not a null pointer, the converted characters are stored into the array pointed to by dst. Conversion continues up to and including a terminating null character, which is also stored. Conversion stops early in either of the following cases:

Each conversion takes place as if by a call to the mbrtowc() function.

If dst is not a null pointer, the pointer object pointed to by src is assigned either a null pointer (if conversion stopped due to reaching a terminating null character) or the address just past the last character converted (if any). If conversion stopped due to reaching a terminating null character and dst is not a null pointer, the resulting state described is the initial conversion state.

If the specified state pointer is null, the mbsrtowcs() function uses its own internal mbstate_t object, which is initialized at program startup to the initial conversion state. Otherwise, the specified mbstate_t object is used to completely describe the current conversion state of the associated character sequence.

The behavior of this function is affected by the LC_CTYPE category of the current locale.

The mbsnrtowcs() function behaves identically to mbsrtowcs(), except that conversion stops after reading at most nms bytes from the buffer pointed to by src.

mbsrtowcs_l() and mbsnrtowcs_l() behave in the same way as mbsrtowcs() and mbsnrtowcs() without the _l suffix, but uses the specified locale rather than the global or per-thread locale. A locale_t is returned by newlocale().


PARAMETERS

dst 

Destination buffer to receive converted characters. This can be a null pointer if no conversion is desired.

src 

Pointer to the string to be converted. If dst is not null, the referenced pointer is updated as described above.

nms 

Stop reading src after nms bytes.

len 

Maximum number of wide characters to write to dst, if dst is not null.

ps 

Conversion state. If this is null, an internal mbstate_t object is used.

locale 

Is a locale_t perhaps returned by newlocale() or LC_GLOBAL_LOCALE or 0 for the current thread locale set with uselocale().


RETURN VALUES

If the input conversion encounters a sequence of bytes that do not form a valid character, an encoding error occurs. In this case, the mbsrtowcs() class of functions set errno to EILSEQ and returns -1; the conversion state is undefined. Otherwise, it returns the number of characters successfully converted, not including the terminating null (if any).


CONFORMANCE

mbsrtowcs() conforms to ANSI/ISO 9899:1999 'ISO C99'

mbsrtowcs_l() conforms to IEEE Std 1003.1-2008 'POSIX.1'

mbsnrtowcs_l() and mbsnrtowcs_l() are BSD UNIX extensions to the standard.


MULTITHREAD SAFETY LEVEL

MT-Safe, with exceptions.

The mbsrtowcs() and mbsnrtowcs() functions are MT-Safe as long as no thread calls setlocale() while one of these functions is executing.

The functions mbsrtowcs_l() and mbsnrtowcs_l() are MT-Safe as long as no thread calls freelocale() on locale while one of these functions is executing.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
mbrlen(), mbrlen_l(), mbrtowc(), mbrtowc_l(), mbsinit(), mbsinit_l(), newlocale(), setlocale(), wcrtomb(), wcrtomb_l(), wcsrtombs(), wcsrtombs_l()


PTC MKS Toolkit 10.5 Documentation Build 40.