18,356
社区成员
发帖
与我相关
我的任务
分享
//**************************************
// unicode字符串转utf8字符串
// 返回大于0成功,小于0失败
//**************************************
int
ustr_u8str( WCHAR *unicodestr, char *utf8str )
{
int result = 0;
try
{
int needlen = WideCharToMultiByte( CP_UTF8, 0, unicodestr, -1, NULL, 0, NULL, NULL );
if( needlen < 0 )
{
return needlen;
}
result = WideCharToMultiByte( CP_UTF8, 0, unicodestr, -1, utf8str, needlen + 1, NULL, NULL );
if( result < 0 )
{
return result;
}
return ( result - 1 );
}
catch( ... )
{
ShowError();
}
return result;
}