User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:stdlib.h:mbstowcs

mbstowcs

    #include <stdlib.h>
    size_t mbstowcs(schar_t *pwcs, const char *str, size_t n);
 

Description

mbstowcs converts multibyte characters to wide characters

mbstowcs c sourcecode example

/* 
 * mbstowcs example code
 * http://code-reference.com/c/stdlib.h/mbstowcs 
 */
#include <stdio.h>
#include <stdlib.h>
 
int main( void )
{
    char      mbinput[8] =  "\x54\x65\x73\x74\x20\x31\x32";
    wchar_t   output[8];
    size_t    wcssize;
 
    wcssize = mbstowcs(output, mbinput, 8);
 
    printf("mbstowcs returned %d\n", wcssize);
 
    printf("output: 0x%.4x 0x%.4x 0x%.4x 0x%.4x 0x%.4x 0x%.4x 0x%.4x \n",
            output[0], output[1], output[2], output[3], output[4], output[5], output[6], output[7]);
 
return 0;
}

output of mbstowcs example

  user@host:~/code-reference.com#  .//mbstowcs2 
  mbstowcs returned 7
  output: 0x0054 0x0065 0x0073 0x0074 0x0020 0x0031 0x0032 

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdlib.h/mbstowcs.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz