Dont ask me, just put it on the table here.I can throw something together in 5-10 minutes if you want it. Plain hex to bin converter that is...
Last edited:
Dont ask me, just put it on the table here.I can throw something together in 5-10 minutes if you want it. Plain hex to bin converter that is...
Do what you think is best. I have time so no rush.If you can hold on a bit I can re-create my hex editor in Pascal which would be standalone..
This no frills code will convert a series of hex characters to binary. You can put any separators you want between the hex digits, but A-F must be capitalized. Max line length is 255 characters.Dont ask me, just put it on the table here.
void main() {
char *cptr, buf[256];
int fd;
unsigned char num, needLowNibble;
FILE *fpi, *fpo;
fpi = fopen("hex2bin.dat", "r");
fpo = fopen("hex2bin.bin", "w");
while (fgets(buf, sizeof(buf), fpi) != NULL) {
cptr = buf;
needLowNibble = 1;
while (*cptr) {
if (isdigit(*cptr) ||
(*cptr >= 'A' && *cptr <= 'F' )) {
if (needLowNibble) {
num = (*cptr >= 'A' ? *cptr - 55 : *cptr - '0') << 4;
needLowNibble = 0;
} else {
num |= (*cptr >= 'A' ? *cptr - 55 : *cptr - '0') << 4;
fwrite(&num, 1, 1, fpo);
needLowNibble = 1;
}
}
*cptr++;
}
}
fclose(fpi);
fclose(fpo);
exit(0);
}
