Binary in "big endian" representation

Discussion in 'Ruby' started by David B., Apr 21, 2008.

  1. David B.

    David B. Guest

    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
    --
    Posted via http://www.ruby-forum.com/.
    David B., Apr 21, 2008
    #1
    1. Advertising

  2. 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

    --
    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!
    David A. Black, Apr 21, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hicham
    Replies:
    2
    Views:
    9,004
    dxcoder
    Jul 2, 2003
  2. Ernst Murnleitner

    float: IEEE, big endian, little endian

    Ernst Murnleitner, Jan 13, 2004, in forum: C++
    Replies:
    0
    Views:
    850
    Ernst Murnleitner
    Jan 13, 2004
  3. invincible

    Little Endian to Big Endian

    invincible, Jun 14, 2005, in forum: C++
    Replies:
    9
    Views:
    14,322
    Old Wolf
    Jun 14, 2005
  4. invincible
    Replies:
    1
    Views:
    536
    red floyd
    Jun 14, 2005
  5. Replies:
    5
    Views:
    333
    Stephen Sprunk
    Aug 31, 2006
Loading...

Share This Page