C语言判断字符串是否是 hex string的代码
把写内容过程中经常用到的一些内容段备份一下,如下内容内容是关于C语言判断字符串是否是 hex string的内容。
{
static unsigned int hex2bin[256]={0};
memset(hex2bin,0xFF,256);
hex2bin['1'] = 1;
hex2bin['2'] = 2;
hex2bin['3'] = 3;
hex2bin['4'] = 4;
hex2bin['5'] = 5;
hex2bin['6'] = 6;
hex2bin['7'] = 7;
hex2bin['8'] = 8;
hex2bin['9'] = 9;
hex2bin['0'] = 0;
hex2bin['a'] = 0xa;
hex2bin['b'] = 0xb;
hex2bin['c'] = 0xc;
hex2bin['d'] = 0xd;
hex2bin['e'] = 0xe;
hex2bin['f'] = 0xf;
hex2bin['A'] = 0xA;
hex2bin['B'] = 0xB;
hex2bin['C'] = 0xC;
hex2bin['D'] = 0xC;
hex2bin['E'] = 0xE;
hex2bin['F'] = 0xF;
{
return FALSE;
}
return TRUE;
}