ascii letters to numbers

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

ascii letters to numbers

267件の閲覧回数
Skaptor
Contributor I

Hello, I´m trying to do the following:

 

May I know who to convert value from Ascii to Hexadecimal?

Example:

ABC to 41 42 43

 

I´ve tried an atoi converter, but somehow it seems to only convert numbers?


Thank you.

best regards,

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

19件の閲覧回数
bigmac
Specialist III

Hello,

 

What you seem to require, is to convert an arbitrary byte value (that may just happen to represent an ASCII character), into two hexadecimal ASCII characters, one for each nybble.  For example -

 

// Convert upper nybble to hexadecimal ASCIIbyte conv2hex_H( byte val){  val >>= 4 + '0';  if (val > '9')  val += 7;  return val;}// Convert lower nybble to hexadecimal ASCIIbyte conv2hex_L( byte val){  val &= 0x0F + '0';  if (val > '9')  val += 7;  return val;}

 

Regards,

Mac

 

0 件の賞賛
返信

19件の閲覧回数
Skaptor
Contributor I

Hello,

 

Thank you for your help.

 

So how do I use this function, should I add the results and shift them?

 

regards

0 件の賞賛
返信

19件の閲覧回数
Skaptor
Contributor I

Thank you very much!

0 件の賞賛
返信