void binary_to_ascii(char *input, int inpuSize, char *output, int outSize)
{
int i, j;
char* poutput;
char high, low;
for (i = 0; i < inpuSize; i++)
{
//printf("%02x: \n", input[i]);
low = (input[i] & 0xF);
if (low < 10 && low >=0)
{
output[i * 2 + 1] = low + '0';
}
else if (low >= 10)
{
output[i * 2 + 1] = low - 10 + 'a';
}
//printf("%02x ", output[i * 2 + 1]);
high = ((input[i] >> 4) & 0xF);
if (high < 10 && high >= 0)
{
output[i * 2] = high + '0';
}
else if (high >= 10)
{
output[i * 2] = high - 10 + 'a';
}
//printf("%02x ", output[i * 2]);
//if (i % 16 == 0)
//printf("\n");
}
}
二进制代码转为ASCII字符串
最新推荐文章于 2024-05-06 00:00:00 发布