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/m/mbstowcs.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/m/mbstowcs.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/m/mbstowcs.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/m/mbstowcs.html on line 8
Convert a multibyte-character string into a wide-character string
#include <stdlib.h>
size_t mbstowcs( wchar_t * pwcs,
const char * s,
size_t n );
- pwcs
- A pointer to a buffer where the function can store the wide-character
string.
- s
- The string of multibyte characters that you want to convert.
- n
- The maximum number of wide characters to store in the buffer that
pwcs points to.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The mbstowcs() function converts a sequence of
multibyte characters pointed to by s into their corresponding
wide-character codes pointed to by pwcs, to a maximum of
n wide characters.
It doesn't convert any multibyte characters beyond a NULL
character.
This function is affected by LC_TYPE.
The
mbsrtowcs()
function is a restartable version of mbstowcs().
The number of array elements modified, not including the terminating zero
code, if present, or (size_t)-1 if an invalid multibyte
character was encountered.
|
If the number of elements is equal to n, the array isn't
terminated by a null character. |
- EILSEQ
- Invalid character sequence.
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
char *wc = "string";
wchar_t wbuffer[50];
int i, len;
len = mbstowcs( wbuffer, wc, 50 );
if( len != -1 ) {
wbuffer[len] = '\0';
printf( "%s(%d)\n", wc, len );
for( i = 0; i < len; i++ ) {
printf( "/%4.4x", wbuffer[i] );
}
printf( "\n" );
}
return EXIT_SUCCESS;
}
This produces the output:
string(6)
/0073/0074/0072/0069/006e/0067
ANSI,
POSIX 1003.1
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
errno
mblen(),
mbrlen(),
mbrtowc(),
mbsinit(),
mbsrtowcs(),
mbtowc()
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/m/mbstowcs.html on line 200
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/m/mbstowcs.html on line 200