#include "PalmType.h"
#include "p_util.h"

static CCHAR _cUpAscMapping[] = "0123456789ABCDEF";
static CCHAR _cLowAscMapping[] = "0123456789abcdef";

UCHAR p_char2asc(UCHAR iChar, BOOLEAN bUpper)
{
	if (bUpper)
		return _cUpAscMapping[iChar&0x0f];
	else
		return _cLowAscMapping[iChar&0x0f];
}

void p_char2asc_str(PXCHAR pDst, PXCHAR pSrc, UCHAR iLen, BOOLEAN bUpper)
{
	DCHAR i, iVal, iPos;

	iPos = 0;
	for (i = 0; i < iLen; i ++)
	{
		iVal = pSrc[i];
		pDst[iPos] = p_char2asc((UCHAR)(iVal>>4), bUpper);
		iPos ++;
		pDst[iPos] = p_char2asc(iVal, bUpper);
		iPos ++;
	}
	pDst[iPos] = 0;
}

