# Encode perl -le 'print join " ", map {ord pack "H2", $_} shift =~ /../g' +num # decode perl -le 'print unpack "H*", pack "C*", @ARGV' num1 num2 ... perl -le 'print map {int($_/16).($_%16)} @ARGV' num1 num2 ...
Some examples:
You can use "h" instead of "H" for low nibble first encoding. Single digit components of the number to be encoded should be zero padded.# Encode $ perl -le 'print join " ", map {ord pack "H2", $_} shift =~ /../g +' 019774 1 151 116 # decode $ perl -le 'print unpack "H*", pack "C*", @ARGV' 1 151 116 019774
--
John.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Encode and decode binary-coded decimals
by jryan (Vicar) on Oct 08, 2002 at 16:59 UTC | |
by jmcnamara (Monsignor) on Oct 08, 2002 at 17:44 UTC | |
by jryan (Vicar) on Oct 08, 2002 at 20:23 UTC |