Re: NSString XOR
Re: NSString XOR
- Subject: Re: NSString XOR
- From: Allan Hsu <email@hidden>
- Date: Fri, 15 Jul 2005 18:21:01 -0700
You can also get a Unicode character buffer from a string very easily
and then treat it as a byte array to perform your XOR operation:
UniChar buffer[[string length]];
[string getCharacters:buffer];
Now you have a buffer of length ([string length] * sizeof(UniChar))
that you can do with as you like.
-Allan
--
Allan Hsu <allan at counterpop dot net>
1E64 E20F 34D9 CBA7 1300 1457 AC37 CBBB 0E92 C779
On Jul 15, 2005, at 4:57 PM, Fritz Anderson wrote:
On 15 Jul 2005, at 5:38 PM, Derrick Carlin wrote:
How would I do an XOR on two NSStrings?
Strictly speaking, the question does not make sense. NSString is an
abstraction that covers any of a number of possible underlying
representations. An instance is an indexable sequence of Unicode
characters, but the underlying bytes aren't accessible. If you want
a byte buffer full of characters, you have to commit yourself to an
encoding and convert the NSString to an NSData, which will yield
your bytes.
How would I convert NSString into binary and back?
See -[NSString dataUsingEncoding:], <http://developer.apple.com/
documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/
NSString.html#//apple_ref/doc/uid/20000154-dataUsingEncoding_>
and -[NSString initWithData:encoding:], <http://developer.apple.com/
documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/
NSString.html#//apple_ref/doc/uid/20000154-initWithData_encoding_>
-- F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40counterpop.net
This email sent to email@hidden
_______________________________________________
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