Re: NSString searching for zero
Re: NSString searching for zero
- Subject: Re: NSString searching for zero
- From: Claudius Sailer <email@hidden>
- Date: Sun, 22 Sep 2002 15:52:49 +0200
Am Sonntag, 22.09.02 um 15:19 Uhr schrieb Andreas Mayer:
and this seems a little bit stupid:
if (([text characterAtIndex:0] == 0) && ([text characterAtIndex:1] ==
0) && ([text characterAtIndex:2] == 0) && ([text characterAtIndex:3]
== 0))
What about
[text isEqualToString:@"\0\0\0\0"]; // see 'man printf' for more
escape codes
This doesn't work
This will most likely not work for values > 127 though, since those
could be encoded using more than one byte (unicode).
If you are handling non-character data, it may be better to use NSData
instead of NSString.
Or you could use regular C strings and functions for processing
arbitrary data and move to Cocoa classes only when actually working
with text (not byte streams).
but you gave me the hint
([text cStringLength] == 0)
works :-))
Thanks
Claudius
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.