fix hex_to_ascii

This commit is contained in:
pjht 2019-09-08 13:54:01 -05:00
parent 1b1c3026ba
commit 4cf2945d36

View File

@ -72,6 +72,7 @@ void int_to_ascii(int n,char* str) {
}
void hex_to_ascii(int n, char* str) {
str[0]='\0';
append(str, '0');
append(str, 'x');
char zeros = 0;
@ -82,7 +83,7 @@ void hex_to_ascii(int n, char* str) {
tmp = (n >> i) & 0xF;
if (tmp == 0 && zeros == 0) continue;
zeros = 1;
if (tmp > 0xA) append(str, tmp - 0xA + 'a');
if (tmp >= 0xA) append(str, tmp - 0xA + 'a');
else append(str, tmp + '0');
}