INT PubNumericToBCDStr(_CHR *pcNStr, _INT iNLen, _CHR *pcBCDStr) { _UCHR *pN = pcNStr; _UCHR *pB = pcBCDStr; _UCHR caBuffer[2]; _UCHR cHigh, cLow; _UINT iCount = 0; _UINT iNCount = iNLen / 2 + iNLen % 2; if((pcNStr == NULL) || (pcBCDStr == NULL)) { sprintf(g_caMsg,"[%s:%d] PubNumericToBCDStr input parameter error!",__FILE__, __LINE__); ErrLog(1000, g_caMsg, RPT_TO_LOG, 0, 0); return OPER_FAIL; } for( iCount = 0; iCount < iNCount; iCount++) { if ( (iCount == 0) && (iNLen%2 != 0) ) { memset(caBuffer, ' ', sizeof(caBuffer)); memcpy(caBuffer + 1, pN, 1); cHigh = (_UCHR) ((*(caBuffer + 0) - 0x30) << 4); cLow = (_UCHR) (*(caBuffer + 1) - 0x30); *pB = (_UCHR) ( cHigh + cLow ); pB += 1; pN += 1; } else { cHigh = (_UCHR) ((*(pN + 0) - 0x30) << 4); cLow = (_UCHR) (*(pN + 1) - 0x30); *pB = (_UCHR) ( cHigh + cLow ); pB += 1; pN += 2; } } return OPER_SUCC; }