• 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: NSString to char[]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString to char[]


  • Subject: Re: NSString to char[]
  • From: Will Mason <email@hidden>
  • Date: Sun, 24 Jul 2005 10:59:36 -0700 (PDT)

> I found a solution that works - let me know what you think:
>
>      NSMutableString * path = [thisBundle pathForResource:@"wakein"
> ofType:@""];
>
>      unsigned int lengthOfMessage = [path length];
>      char sysctlPath[lengthOfMessage + 1];
>      strcpy(sysctlPath, [path UTF8String]);

That doesn't work for two reasons. First, you're assuming that the
length of the path in unichars will always be equal to the length of
the path when it's encoded with UTF-8. Second, you're assuming that the
file system's natural encoding is always UTF-8. Both of these
assumptions are false.

Take care,
Will
 _______________________________________________
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

References: 
 >Re: NSString to char[] (From: Jerry Brace <email@hidden>)

  • Prev by Date: Re: NSString to char[]
  • Next by Date: Problem centering inside a scrollview
  • Previous by thread: Re: NSString to char[]
  • Next by thread: Re: NSString to char[]
  • Index(es):
    • Date
    • Thread