Re: NSString to char[]
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