[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Array#pack: byte order for unsigned types
From:       "Jason Voegele" <jason () jvoegele ! com>
Date:       2002-04-12 17:02:25
[Download RAW message or body]

> In message "Re: Array#pack: byte order for unsigned types"
>     on 02/04/12, "Jason Voegele" <jason@jvoegele.com> writes:
> 
> |How, then, do "I", "L", and "S" differ from their signed counterparts?
> 
> No difference in pack, but in unpack.
> Try [-1].pack("i").unpack("i") and [-1].pack("i").unpack("i").

Okay, but then how would I unpack an unsigned integer that is in a 
different byte order from my underlying platform?  Or do I have to do 
this "the long way", by pulling out the individual bytes and constructing 
the number myself?

In other words, I need to read in data over a network connection that may 
or may not be in the same byte order as the architecture my code is running 
on (this is CORBA IIOP if you're wondering).  My platform may be little 
endian while the data I'm reading is big endian.

Thanks again!

-- 
Jason Voegele

"We believe that we invent symbols.  The truth is that they invent us."
    -- Gene Wolfe, The Shadow of the Torturer

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic