Re: Strings
Re: Strings
- Subject: Re: Strings
- From: Ondra Cada <email@hidden>
- Date: Wed, 13 Feb 2002 15:03:37 +0100
bhaller,
>
>>>>> email@hidden (b) wrote at Tue, 12 Feb 2002 22:37:28 -0800:
b> C strings are bad. NSString is gooood.
Incidentally...
I have to parse a quite ugly "string" data, which generally encode values
textually, but _sometimes_ directly (it's Siemenes Gigaset 3070 log answer to
AT^SLOGR -- anybody has direct experience with the thing, let me please know
to share knowledge). Ie. in plain ol' stdlib I would do
something=atoi(buffer+index); // very often
something=buffer[index]; // sometimes
Whilst converting the former to the NSString level (which I do want to use
for its power and simplicity) is naturally trivial, the latter is not:
something=[nsstr characterAtIndex:index];
might generally return Unicode values quite unrelated -- in their numerical
values -- to what was originally in the 8-bit data.
Currently I use ...initWith
Data:rawData encoding:NSASCIIStringEncoding, and
it seems to work well, but I am still not sure:
- is it granted that with NSASCIIStringEncoding the result string will
always contain the same value for characterAtIndex:index as [rawData
bytes][index] would?
- if not, is it at least granted that with NSASCIIStringEncoding the result
string will contain exactly one character for each byte in rawData (so that I
could use directly [rawData bytes][index] instead of
characterAtIndex:index)?
- if not, have you any idea how to parse such a thing (but for using
[rawData bytes] directly, which I don't like the slightest bit -- I use
things like hasSuffix, componentsSeparatedByString, etc. quite often)?
thanks,
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.