FROM : Ricky Sharp
DATE : Tue May 01 03:10:09 2007
On Apr 30, 2007, at 5:00 PM, Martin wrote:
> Hello list,
>
> Can someone point me in the direction of how to sway the byte order
> of data read via NSInputStream?
>
> I am writing an application on a G5 (10.4) that needs to read a
> data file from a Windows Share, I have got the stream reading the
> file, but I guess it is reading in big endian order. What order
> would the bytes be read if the application was on a Intel based Mac?
I believe that the stream is just giving you a stream of bytes.
Having said that, you'll need to look at the data format of your
file. Only then will you know if it contains data that potentially
needs to be swapped.
The file's data is most likely little endian. You can then use APIs
such as NSSwapLittleIntToHost to ensure swapping will occur should
the host computer have a different endianness.
I tend to gravitate though to the CFSwap-based APIs since they
explicitly call out the size (e.g. CFSwapInt64LittleToHost)
___________________________________________________________
Ricky A. Sharp mailto:<email_removed>
Instant Interactive(tm) http://www.instantinteractive.com
DATE : Tue May 01 03:10:09 2007
On Apr 30, 2007, at 5:00 PM, Martin wrote:
> Hello list,
>
> Can someone point me in the direction of how to sway the byte order
> of data read via NSInputStream?
>
> I am writing an application on a G5 (10.4) that needs to read a
> data file from a Windows Share, I have got the stream reading the
> file, but I guess it is reading in big endian order. What order
> would the bytes be read if the application was on a Intel based Mac?
I believe that the stream is just giving you a stream of bytes.
Having said that, you'll need to look at the data format of your
file. Only then will you know if it contains data that potentially
needs to be swapped.
The file's data is most likely little endian. You can then use APIs
such as NSSwapLittleIntToHost to ensure swapping will occur should
the host computer have a different endianness.
I tend to gravitate though to the CFSwap-based APIs since they
explicitly call out the size (e.g. CFSwapInt64LittleToHost)
___________________________________________________________
Ricky A. Sharp mailto:<email_removed>
Instant Interactive(tm) http://www.instantinteractive.com
| Related mails | Author | Date |
|---|---|---|
| Martin | May 1, 00:00 | |
| Ricky Sharp | May 1, 03:10 |






Cocoa mail archive

