static string Hex2String(const char *pBuffer, int iBytes) //转为16进制的string,便于打印
{
string result;
for (int i=0; i<iBytes; i++)
{
unsigned char c;
unsigned char b = pBuffer[i] >> 4;
b &= 0x0f;
if (9 >= b)
{
c = b + '0';
}
else
{
c = (b-10) + 'A';
}
result += (unsigned char)c;
b = pBuffer[i] & 0x0f;
if (9 >= b)
{
c = b + '0';
}
else
{
c = (b-10) + 'A';
}
result += (unsigned char)c;
result += ' ';
}
return result;
}
16进制转为16进制的string
最新推荐文章于 2024-06-28 15:35:20 发布