# Binary in "big endian" representation

**URL:** <https://www.ruby-forum.com/t/binary-in-big-endian-representation/135311>\
**Category:** Ruby\
**Created:** [April 21, 2008, 1:30am UTC](https://www.ruby-forum.com/t/binary-in-big-endian-representation/135311 "2008-04-21T01:30:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [April 21, 2008, 1:30am UTC](https://www.ruby-forum.com/t/binary-in-big-endian-representation/135311/1 "2008-04-21T01:30:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [April 21, 2008, 2:58am UTC](https://www.ruby-forum.com/t/binary-in-big-endian-representation/135311/2 "2008-04-21T02:58:52Z")

</div>

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  
([BitStruct](http://redshift.sourceforge.net/bit-struct/) I think is where it still  
lives) which might help you out.

David
