• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: cString deprecated!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Duplicating PB behaviour (first responder?)
  • Next by Date: Re: Turn off sheet transparency
  • Previous by thread: Re: cString deprecated!
  • Next by thread: How to grab everything in a string before a space?
  • Index(es):
    • Date
    • Thread