ASCII碼轉(zhuǎn)換為BCD碼的代碼:
int A2BCD(BYTE * pDst,const char * pSrc) { ASSERT(pDst != NULL && pSrc != NULL); int nLen = (strlen(pSrc)+1)/2; for(int i = strlen(pSrc)-1; i > 0; i -= 2) { int n1 = pSrc[i] - '0'; int n2 = pSrc[i-1] - '0'; pDst[i/2] = (n1&0xFF)|(n2<<4); } |
|