[En-Nut-Discussion] ASCII to hex
Alexander Baranov
Baranov at intech21.com
Mon Mar 1 17:45:48 CET 2004
Hi
maybe this helps until seniors propose something like atoi()?
unsigned char pack_char_to_hex (unsigned char* psrc)
{
unsigned char m0,m1;
m0 = *psrc;
if((m0 >=0x30)&&(m0<=0x39)){
m0 = m0 - 0x30;
}
else if((m0 >=0x41)&&(m0<=0x46)){
m0 = m0 - 0x41+0x0A;
}
else if((m0 >=0x61)&&(m0<=0x66)){
m0 = m0 - 0x61+0x0A;
}
else{
m0 = 0;
}
m1 = *(psrc + 1);
if((m1 >=0x30)&&(m1<=0x39)){
m1 = m1 - 0x30;
}
else if((m1 >=0x41)&&(m1<=0x46)){
m1 = m1 - 0x41+0x0A;
}
else if((m1 >=0x61)&&(m1<=0x66)){
m1 = m1 - 0x61+0x0A;
}
else{
m1 = 0;
}
return ( (m0<<4)+m1);
}
----- Original Message -----
From: "Sigurd Kleppan" <sigurkl at frisurf.no>
To: <en-nut-discussion at egnite.de>
Sent: Monday, March 01, 2004 10:58 AM
Subject: [En-Nut-Discussion] ASCII to hex
> A simple question?
> I need to convert a ASCII character to it's hex value. Do someone have a
function or a hint.
>
> Thank you!
>
> Sigurd Kleppan
> sigurkl at frisurf.no
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
More information about the En-Nut-Discussion
mailing list