char *和wchar *之间的相互转换
#include #include void main( void ){ int i; char *pmbnull = NULL; char *pmbhello = (char *)malloc( MB_CUR_MAX ); wchar_t *pwchello = L"Hi"; wchar_t *pwc = (wchar_t *)malloc( sizeof( wchar_t )); printf( "Convert to multibyte string:\n" ); i = wcstombs( pmbhello, pwchello, MB_CUR_MAX ); printf( "\tCharacters converted: %u\n", i ); printf( "\tHex value of first" ); printf( " multibyte character: %#.4x\n\n", pmbhello ); printf( "Convert back to wide-character string:\n" ); i = mbstowcs( pwc, pmbhello, MB_CUR_MAX ); printf( "\tCharacters converted: %u\n", i ); printf( "\tHex value of first" ); printf( " wide character: %#.4x\n\n", pwc );}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~