Re: cString deprecated!
Re: cString deprecated!
- Subject: Re: cString deprecated!
- From: Julien Jalon <email@hidden>
- Date: Wed, 4 Sep 2002 12:16:46 +0200
Le mercredi, 4 sep 2002, ` 00:51 Europe/Paris, Ali Ozer a icrit :
I think you should look at my NSString category :
http://softrak.stepwise.com/display?pkg=3033&os=20
I think there might be a little bug in your code; fails to use the
passed in encoding (but uses ISOLatin1 instead)
Ali
- (const char *)cStringUsingEncoding:(NSStringEncoding)encoding {
char *returnValue;
NSData *encodedData=[self
dataUsingEncoding:NSISOLatin1StringEncoding >> allowLossyConversion:YES];
unsigned dataLength=[encodedData length];
returnValue = [[NSMutableData dataWithLength:dataLength+1]
mutableBytes];
memcpy(returnValue,(char *)[encodedData bytes],dataLength);
returnValue[dataLength]='\0';
return returnValue;
}
Oups... maybe :-)
Of course, change NSISOLatin1StringEncoding to encoding...
It's fixed in version 1.1 at :
http://mapage.noos.fr/jalon/CocoaCodes/CocoaCStringEncoding-1.1.tar.gz
--
Julien Jalon
http://www.julien-jalon.org/ -
http://nuxeo.com/
_______________________________________________
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.