Aug 24, 2006 #1 Maverickmax Advanced Member level 1 Joined Dec 6, 2004 Messages 404 Helped 8 Reputation 16 Reaction score 3 Trophy points 1,298 Activity points 3,689 hex to ascii algorithm Hi Does anyone have a code of implementing hex to ascii conversion algorithm? Or explain me how to do it Thank you Maverick Max
hex to ascii algorithm Hi Does anyone have a code of implementing hex to ascii conversion algorithm? Or explain me how to do it Thank you Maverick Max
Aug 24, 2006 #2 A alvarorahul Advanced Member level 4 Joined Apr 13, 2005 Messages 110 Helped 6 Reputation 12 Reaction score 1 Trophy points 1,298 Activity points 2,062 convert hexadecimal ascii-code algorithm could you please specify a little more.....maybe give an example of what exactly you want to do ???
convert hexadecimal ascii-code algorithm could you please specify a little more.....maybe give an example of what exactly you want to do ???
Aug 24, 2006 #3 Maverickmax Advanced Member level 1 Joined Dec 6, 2004 Messages 404 Helped 8 Reputation 16 Reaction score 3 Trophy points 1,298 Activity points 3,689 Right Basically when I transmit simple data such as 'A' and I have found out that the receiver need to read hex. Therefore I would like to convert hex into ascii so that I can display characters on my LCD module Maverick Max
Right Basically when I transmit simple data such as 'A' and I have found out that the receiver need to read hex. Therefore I would like to convert hex into ascii so that I can display characters on my LCD module Maverick Max
Aug 24, 2006 #4 I indi2go Junior Member level 2 Joined May 31, 2001 Messages 23 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 98 There are different methods.. one possible solution (quick & dirty, no range checking): Code: const h2c[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46}; unsigned char hex_number; char ascii_char; main() { hex_number=0xA; //Number to convert ascii_char=h2c[hex_number]; //ASCII-Code for hex_number }
There are different methods.. one possible solution (quick & dirty, no range checking): Code: const h2c[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46}; unsigned char hex_number; char ascii_char; main() { hex_number=0xA; //Number to convert ascii_char=h2c[hex_number]; //ASCII-Code for hex_number }
Aug 24, 2006 #5 lambtron Full Member level 5 Joined Nov 2, 2005 Messages 251 Helped 34 Reputation 68 Reaction score 8 Trophy points 1,298 Location Portland, OR Activity points 3,546 Here's a simple way to convert a hex nibble (h) to its ascii character equivalent (a): Code: a=h+((h>9)?55:49);
Here's a simple way to convert a hex nibble (h) to its ascii character equivalent (a): Code: a=h+((h>9)?55:49);