• 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: Why is NSString->FSRef so hard?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is NSString->FSRef so hard?


  • Subject: Re: Why is NSString->FSRef so hard?
  • From: Erg Consultant <email@hidden>
  • Date: Mon, 27 Apr 2009 21:18:24 -0700 (PDT)

FSPathMakeRef did not work - which drove me to find some other way such an NSString->CFURL->FSRef. Reading the string in from a file as an NSString does however work for making the original path string without magling the characters - reading the same string from the same file as a CFStringRef however does not work - the special characters get mangled.

Erg




________________________________
From: Ken Thomases <email@hidden>
To: Erg Consultant <email@hidden>
Cc: email@hidden
Sent: Saturday, April 25, 2009 6:12:33 PM
Subject: Re: Why is NSString->FSRef so hard?

On Apr 25, 2009, at 8:03 PM, Erg Consultant wrote:

> On Apr 25, 2009, at 7:48 PM, Stephen J. Butler wrote:
>
>> On Sat, Apr 25, 2009 at 7:28 PM, Erg Consultant
>> <email@hidden> wrote:
>>> I was using CFURLGetFSRef passing in the NSString which works fine as long as the path contains no special chars. If it does, CFURLGetFSRef returns nil.
>>
>> CFURLGetFSRef is great if what you have originally is a CF/NSURL. But
>> if you just have an NSString, you might as well use FSPathMakeRef with
>> [aString fileSystemRepresentation]. No reason to create an
>> intermediary NSURL.

> When I do that, the conversion from NSString to const UInt8 * path mangles the special characters in the path.

What do you mean mangles?  I suspect you're misinterpreting "encodes" as mangles.  Asking a file path string for its -fileSystemRepresentation is asking it to encode the string into the form expected by various APIs which take file paths in C strings (of 8-bit characters).  Of course this won't look like the original Unicode string contents; Unicode can't fit into 8-bit characters without being encoded somehow.

But the question is, why do you care?  Did FSPathMakeRef work, when passed such a string?  It should, which is all you're interested in.

Regards,
Ken



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Why is NSString->FSRef so hard? (From: Erg Consultant <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Nick Zitzmann <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Erg Consultant <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: "Stephen J. Butler" <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Erg Consultant <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Why is NSString->FSRef so hard?
  • Next by Date: Re: Why is NSString->FSRef so hard?
  • Previous by thread: Re: Why is NSString->FSRef so hard?
  • Next by thread: Re: Why is NSString->FSRef so hard?
  • Index(es):
    • Date
    • Thread