16,472
社区成员
发帖
与我相关
我的任务
分享
char *
u2s( unsigned char *buf, unsigned short length, char *tmpbuf )
{
int i;
char *p;
char s[ 100 ] = "";
wchar_t wstr[ 1 ];
CString mstr;
*tmpbuf = 0;
mstr = _T( "" );
for( i = 0; i < ( int )length; i += 2 )
{
p = ( char * )wstr;
*p = *( buf + 1 ); //high
*( p + 1 ) = *buf; //low
mstr = wstr;
memset( s, 0, sizeof( s ) );
strcat( s, ( const char * )mstr );
if( *buf ) //if low is not 0
{
s[ 2 ] = 0;
}
else
{
s[ 1 ] = 0;
}
strcat( tmpbuf, ( const char * )s );
buf += 2;
}
return tmpbuf;
}