help needed regarding conversion of hex to binary
Is there a (easy and ready) way to convert hexa to binary. I mean, convert data that was transformed    x := myData asByteArray hex. back to binary?
On Tue, Sep 12, 2017 at 2:55 AM, Casimiro de Almeida Barreto < casimiro.barreto@gmail.com> wrote:
Is there a (easy and ready) way to convert hexa to binary. I mean, convert data that was transformed
x := myData asByteArray hex.
back to binary?
I thought I'd try what usually works... World > Tools > Finder > Examples First to test what we know... #(9 10 11 12) asByteArray . '090a0b0c' results in #hex but the reverse... '090a0b0c' . #(9 10 11 12) asByteArray . doesn't show any result, so perhaps there is no easy way. But this might give you a starting point... hexString := #(9 10 11 12) asByteArray hex. (NumberParser on: '16r', hexString) nextInteger asByteArray " ==> #[9 10 11 12]" cheers -ben
ByteArray readHexFrom: #[ 0 1 2 3 4 5 6 7 8 9 10 ] hex.
On 12 Sep 2017, at 14:47, Ben Coman <btc@openinworld.com> wrote:
On Tue, Sep 12, 2017 at 2:55 AM, Casimiro de Almeida Barreto <casimiro.barreto@gmail.com> wrote: Is there a (easy and ready) way to convert hexa to binary. I mean, convert data that was transformed
x := myData asByteArray hex.
back to binary?
I thought I'd try what usually works... World > Tools > Finder > Examples First to test what we know... #(9 10 11 12) asByteArray . '090a0b0c' results in #hex
but the reverse... '090a0b0c' . #(9 10 11 12) asByteArray . doesn't show any result, so perhaps there is no easy way.
But this might give you a starting point... hexString := #(9 10 11 12) asByteArray hex. (NumberParser on: '16r', hexString) nextInteger asByteArray " ==> #[9 10 11 12]"
cheers -ben
participants (3)
-
Ben Coman -
Casimiro de Almeida Barreto -
Sven Van Caekenberghe