in reply to hex to ascii, oct to ascii, and back?
I am not sure what exactly you mean by ascii to hex and oct. Are you talking about converting a string representation like "0755" or "0x55" ? If yes, then look at oct and hex.
Otherwise maybe you want to get the ascii value of a character and represent it as oct or hex. Use ord to get the ascii value and then printf %o for oct and printf %x for hex. The formatting codes for printf are explained here
After re-reading the link you included I think I have a better understanding of what you are asking for. Some code below
octal
perl -e 'printf("%o", ord) foreach ( split //, shift )'hex
perl -e 'printf("%x", ord) foreach ( split //, shift )'<cite>Just a tongue-tied, twisted, earth-bound misfit. -- Pink Floyd</cite>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: hex to ascii, oct to ascii, and back?
by Anonymous Monk on Mar 05, 2002 at 04:56 UTC |