Binary in "big endian" representation

Hello,

I would like to convert an input (like a file, or a password) into
binary format. After reading my Ruby in a nutshell book, I belive I can
use this method:
unpack(‘C*’)

But do the binary representation will respect the big endian convention?

Thank you.

David

Hi –

On Mon, 21 Apr 2008, David B. wrote:

Hello,

I would like to convert an input (like a file, or a password) into
binary format. After reading my Ruby in a nutshell book, I belive I can
use this method:
unpack(‘C*’)

But do the binary representation will respect the big endian convention?

I can’t quite picture what you want the result to be. unpack will give
you an array. Did you want to do something with that?

I’ll add that pack and unpack have a bunch of endian-specific
arguments, and also there’s the BitStruct package by Joel VanderWerf
(http://redshift.sourceforge.net/bit-struct/ I think is where it still
lives) which might help you out.

David

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs