• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Byte swapping using NSInputStream
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Byte swapping using NSInputStream


  • Subject: Re: Byte swapping using NSInputStream
  • From: Ricky Sharp <email@hidden>
  • Date: Mon, 30 Apr 2007 20:10:09 -0500


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@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Byte swapping using NSInputStream (From: Martin <email@hidden>)

  • Prev by Date: Re: NSImageView setAnimates:YES... PLEASE?
  • Next by Date: User Defaults
  • Previous by thread: Byte swapping using NSInputStream
  • Next by thread: NSManagedObjects bound to an NSPopUpBotton in a toobar
  • Index(es):
    • Date
    • Thread