User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:stdlib.h:wctomb
click
to support this page (eg 0,42 € or so) Thanks.

wctomb

    #include <stdlib.h>
    int wctomb(char *str, wchar_t wchar); 
 

Description

wctomb converts a wide character to a multibyte character in the string.
wctomb maximum MB_CUR_MAX sign stores in a string.
The behavior of wctomb is affected by the LC_CTYPE category of the current locale

  <setlocale.h> is for this example nessesary

wctomb C Sourcecode Example

/* 
 * wctomb example code
 * http://code-reference.com/c/stdlib.h/wctomb 
 */
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
 
int main(void)
{
   static char string[5];
   wchar_t wchar = L'é';
   int length;
 
   setlocale(LC_ALL, "");
   length = wctomb(string, wchar);
   printf("number of bytes in the multibyte character : %i\n", length);
   printf("converted string : \"%s\"\n", string);
   return 0;
}

output of wctomb example

  user@host:~/code-reference.com#  ./wctomb 
  number of bytes in the multibyte character : 2
  converted string : "é"
advertising
c/stdlib.h/wctomb.txt · Last modified: 2013/01/22 22:02 (external edit)

Impressum