Convert a character to it's 8 bits value

Hi everyone,

I want to get the binary value of a character in a string and store that in a byte type variable, is it possible? How can I manage to do that?

If I do:

String inputString = "sab";
byte binaryValue = String(inputString[1],BIN));

it does not work...

Thanks in advance,

Alex

just use char based traditional c strings and you have it right there, no calculation necessary.

char inputString[8] = "sab";
//...
byte binaryvalue = inputString[1]; // yields 97, the base 10 ASCII value for 'a'

Oh that's actually easy. Thanks!