Re: NSStrings and data bytes
Re: NSStrings and data bytes
- Subject: Re: NSStrings and data bytes
- From: Damien Sorresso <email@hidden>
- Date: Mon, 26 Jun 2006 22:58:27 -0500
On 26 Jun, 2006, at 9:31 PM, D.K. Johnston wrote:
I want to read the bytes from a file as an NSString so I can use
scanners, etc. But then I need to get at the original bytes in
order to process them. (Sometimes I even have to get the right and
left nibbles of a byte.) I've been playing around with NSString
methods like cStringUsingEncoding:, but I can't seem to get the
bytes back. Any suggestions?
Go the other way around. Read the bytes into an NSData object and
then use initWithData:encoding: to get the string for your text,
specifying the proper encoding, of course. From there, just do your
work with NSScanner on that object. (I assume the order in which your
data and string are created doesn't matter.)
You can also use NSString's initWithBytes:length:encoding: if you
just want to read in the data using the standard C libraries.
--
Damien Sorresso
Mac OS X Developer
Computer Infrastructure Support Services
Illinois State University
E-mail: email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden