wctomb 百科内容来自于: 百度百科

函数介绍

函数作用

wctomb将一个宽字符转化为多字节字符

函数返回值

If wctomb converts the wide character to a multibyte character, it returns the number of bytes (which is never greater than MB_CUR_MAX) in the wide character. If wchar is the wide-character null character (L'\0'), wctomb returns 1. If the conversion is not possible in the current locale, wctomb returns –1.

函数参数说明

mbchar
The address of a multibyte character
wchar
A wide character
Remarks
The wctomb function converts its wchar argument to the corresponding multibyte character and stores the result at mbchar. You can call the function from any point in any program.

函数应用举例

Example
/* WCTOMB.CPP illustrates the behavior of the wctomb function */
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
int i; wchar_t wc = L'a';
char *pmbnull = NULL;
char *pmb = (char *)malloc( sizeof( char ) );
printf( "Convert a wide character:\n" );
i = wctomb( pmb, wc );
printf( "\tCharacters converted: %u\n", i );
printf( "\tMultibyte character: %.1s\n\n", pmb );
printf( "Attempt to convert when target is NULL:\n" );
i = wctomb( pmbnull, wc );
printf( "\tCharacters converted: %u\n", i );
printf( "\tMultibyte character: %.1s\n", pmbnull );}
Output
Convert a wide character: Characters converted: 1 Multibyte character: aAttempt to convert when target is NULL: Characters converted: 0 Multibyte character: (
$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定