Hi all, i am trying to convert an hex string into a byte array since i need to send it trough a socket to a server. Actually i have a string like this:
'Assuming' the numerals will always have a leading zero, starting at the second character subtract 48 (see an ASCII table for why) from every other character. Print to the serial monitor for proof.
dougp:
'Assuming' the numerals will always have a leading zero, starting at the second character subtract 48 (see an ASCII table for why) from every other character. Print to the serial monitor for proof.
AWOL:
...but don't forget to allow for a..f and A..F
The OP is interested for numerical data which is obvious from this declaration: byte a[]={0x00,0x03,0x04,0x05}. Are a..f and A..F equivalent? If not, why are you insisting on taking care of a..f?
GolamMostafa:
The OP is interested for numerical data which is obvious from this declaration: byte a[]={0x00,0x03,0x04,0x05}.
Maybe. But, oftentimes once an answer has seemingly been provided the OP will add a post such as: "That's great! Now I need to add xxx to complete this level."
GolamMostafa:
Are a..f and A..F equivalent? If not, why are you insisting on taking care of a..f?
On the aforementioned ASCII table they're not. And, since a lot of data comes via ASCII...
It's just accommodating the sender using either upper or lower case.