Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : mbsrtowcs

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

Return Type : size_t

Platform-specific unsigned type for array indices and memory sizes.
Read about return values of mbsrtowcs function .

1st Parameter Type : wchar_t *

A pointer to a wide-character string, where each element is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets.

1st Parameter

Pointer to the destination wide-character array where the converted wide characters will be stored. If `dst` is `NULL`, no conversion is performed, and the function simply returns the number of wide characters required.

2nd Parameter Type : const char **

A pointer to a pointer to a constant multibyte string. The inner pointer may be updated by functions to point to the next unprocessed character, but the string data itself cannot be modified.

2nd Parameter

Pointer to a pointer to the multibyte character string to be converted. The pointer is updated to point to the next unconverted character after the function call.

3rd Parameter Type : size_t

Platform-specific unsigned type for array indices and memory sizes.

3rd Parameter

The maximum number of wide characters to write to the destination array, including the null terminator.

4th Parameter Type : mbstate_t *

A pointer to an `mbstate_t` object that represents the current shift state for multibyte to wide character conversions. This pointer allows modification of the state during the conversion process.

4th Parameter

Pointer to a `mbstate_t` object representing the current conversion state. If `NULL`, the function uses the internal static state.

Read more about parameters of mbsrtowcs in parameters section
The mbsrtowcsfunction in C language Converts a multibyte string to a wide character string.
The mbsrtowcs function converts a sequence of multibyte characters to a sequence of corresponding wide characters. It stores not more than n wide characters into the array pointed to by dst. It stops if it encounters a null character or if an encoding error occurs. The conversion state is stored in the object pointed to by ps.
The mbsrtowcsfunction takes 4 parameters:
  • wchar_t * `dst`: Pointer to the destination wide-character array where the converted wide characters will be stored. If `dst` is `NULL`, no conversion is performed, and the function simply returns the number of wide characters required.
  • const char ** `src`: Pointer to a pointer to the multibyte character string to be converted. The pointer is updated to point to the next unconverted character after the function call.
  • size_t `len`: The maximum number of wide characters to write to the destination array, including the null terminator.
  • mbstate_t * `ps`: Pointer to a `mbstate_t` object representing the current conversion state. If `NULL`, the function uses the internal static state.
Converts a multibyte character string to a wide-character string, storing the result in the array pointed to by `dst`. Considers at most `len` wide characters, including the null terminator, and updates `src` to point to the next unconverted character. Returns the number of wide characters written (excluding the null terminator) or `(size_t)-1` if an encoding error occurs. If `dst` is `NULL`, the function returns the number of wide characters that would be written.
The mbsrtowcs function return value :
  • Returns the number of wide characters successfully converted, not including the terminating null character
  • If an encoding error occurs, it returns (size_t)(-1) and sets errno to EILSEQ

Output

This example demonstrates basic usage of mbsrtowcs to convert a multibyte string to a wide character string.