• 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: Non-nil terminated C string to NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non-nil terminated C string to NSString


  • Subject: Re: Non-nil terminated C string to NSString
  • From: John Stiles <email@hidden>
  • Date: Wed, 2 Aug 2006 18:08:46 -0700

Does initWithBytes:length:encoding: work for you?
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ Classes/NSString_Class/Reference/Reference.html#//apple_ref/occ/instm/ NSString/initWithBytes:length:encoding:


On Aug 2, 2006, at 6:00 PM, Ben Phipps wrote:

I want to turn a non-nil terminated c string (such as the one received from Keychain) into an NSString. Since stringWithCString:length: is deprecated in 10.4, what is the correct way to do this?

Creating an NSString then asking for a substring seems wasteful as the initial string could be huge. And inserting a null character into the c string doesn't work since I could be corrupting memory. Any suggestions?

Thanks,
Ben
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com


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
  • Follow-Ups:
    • Re: Non-nil terminated C string to NSString
      • From: Ken Tozier <email@hidden>
    • Re: Non-nil terminated C string to NSString
      • From: Ben Phipps <email@hidden>
References: 
 >Non-nil terminated C string to NSString (From: Ben Phipps <email@hidden>)

  • Prev by Date: Non-nil terminated C string to NSString
  • Next by Date: Re: Non-nil terminated C string to NSString
  • Previous by thread: Non-nil terminated C string to NSString
  • Next by thread: Re: Non-nil terminated C string to NSString
  • Index(es):
    • Date
    • Thread