Binary in "big endian" representation

D

David B.

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
 
D

David A. Black

Hi --

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

--
Rails training from David A. Black and Ruby Power and Light:
INTRO TO RAILS June 9-12 Berlin
ADVANCING WITH RAILS June 16-19 Berlin
INTRO TO RAILS June 24-27 London (Skills Matter)
See http://www.rubypal.com for details and updates!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top