Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/w/wctomb.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/w/wctomb.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/w/wctomb.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/w/wctomb.html on line 8
Convert a wide character into a multibyte character
#include <stdlib.h>
int wctomb( char * s,
wchar_t wc );
- s
- NULL, or a pointer to a location where the function
can store the multibyte character.
- wc
- The wide character that you want to convert.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The wctomb() function determines the number of bytes required to
represent the multibyte character corresponding to the code contained in
wc. If s isn't NULL, the
multibyte character representation is stored in the array it points to. At most MB_CUR_MAX characters are stored.
- If s is NULL:
- 0
- The wctomb() function uses locale specific multibyte character encoding that's not state-dependent.
- >0
- The function is state-dependent.
- If s isn't NULL:
- -1
- If the value of wchar doesn't correspond to a valid multibyte character.
- x
- The number of bytes that comprise the multibyte character corresponding to the value of wchar.
#include <stdio.h>
#include <stdlib.h>
wchar_t wchar = { 0x0073 };
char mbbuffer[MB_CUR_MAX];
int main( void )
{
int len;
printf( "Character encodings do %shave "
"state-dependent \nencoding.\n",
( wctomb( NULL, 0 ) )
? "" : "not " );
len = wctomb( mbbuffer, wchar );
mbbuffer[len] = '\0';
printf( "%s(%d)\n", mbbuffer, len );
return EXIT_SUCCESS;
}
This produces the output:
Character encodings do not have state-dependent
encoding.
s(1)
ANSI,
POSIX 1003.1
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
wcrtomb(),
wcsrtombs(),
wcstod(), wcstof(), wcstold(),
wcstoimax(), wcstoumax(),
wcstok(),
wcstol(), wcstoll(),
wcstombs(),
wcstoul(), wcstoull(),
wctob()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/w/wctomb.html on line 188
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/w/wctomb.html on line 188