• 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
path names with spaces
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

path names with spaces


  • Subject: path names with spaces
  • From: Andreas Wolf <email@hidden>
  • Date: Wed, 16 Jan 2002 17:01:53 -0800

Does anybody know how to create a UNIX filesystem representation of
a path that includes whitespaces?

I ran into weird situations when trying to popen() a path that
was retrieved with -(NSString*) pathForResource:ofType because the path
name for that resource contains a space character. The shell that gets invoked
implicitly interprets the space as a delimiter for the path.

First, -(const char*) fileSystemRepresentation didn't help at all. I expected that it
would replace the space character by '\ '.
Also, I couldn't just programmatically insert a '\' before the space because cocoa doesn't seem to handle
that character quite right.

For example:

char n[2];
n[0]=0x5c; // backslash character
n[1]=0x0; // c string delimiter
NSLog([NSString stringWithCString:n];

what I get as output are four backslash characters ("\\\\").
Is there a bug in how cocoa handles the \ character?

Thanks,
-Andreas


  • Follow-Ups:
    • Re: path names with spaces
      • From: Markus Hitter <email@hidden>
    • Re: path names with spaces
      • From: Ben Jansen <email@hidden>
  • Prev by Date: NSTableView font weirdness
  • Next by Date: Re: path names with spaces
  • Previous by thread: NSTableView font weirdness
  • Next by thread: Re: path names with spaces
  • Index(es):
    • Date
    • Thread