• 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: Escaping white space in an NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Escaping white space in an NSString


  • Subject: Re: Escaping white space in an NSString
  • From: Sherm Pendley <email@hidden>
  • Date: Thu, 21 May 2009 09:29:50 -0400

On Thu, May 21, 2009 at 2:26 AM, Bruce Johnson <email@hidden>wrote:

> > Post your croaking code.  You seem to have some misapprehensions about
> how
> > command-line arguments work,
>

> No misapprehensions here.


Sorry, but I'm afraid there are.


> > What CLI were you planning to run on iPhone?
> The CLI is for a Cocoa App


There's no CLI at all in the code you posted.


> char  mdfile[PATHSIZE];
> strncpy(mdfile, <pathToFile>, MAXREAD);
>
> FILE * stream = fopen(<pathToFile>, "rt");
>
...

>
> So as you can see, a non-escaped, white space laden "pathToFile" will
> return a bogus FILE *stream.


No it won't. Spaces are only relevant to commands typed into a shell, or
used in a shell script. They're used by the shell to split its input into
the path to a command, and arguments to pass to it.

Spaces, and other characters that are meaningful when used in a shell, such
as <, >, &, $, or |, are of no importance whatsoever when passed to fopen.
No escaping or quoting is necessary.

To see what's really going on, try this immediately after your fopen:

if (NULL == stream)
    NSLog(@"Could not open '%s': %s", pathToFile, strerror(errno));

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________

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: 
 >Re: Escaping white space in an NSString (From: Greg Guerin <email@hidden>)
 >Re: Escaping white space in an NSString (From: Bruce Johnson <email@hidden>)

  • Prev by Date: Re: How to disable application menu bar item
  • Next by Date: Feed Parsing Framework ...
  • Previous by thread: Re: Escaping white space in an NSString
  • Next by thread: Re: Escaping white space in an NSString
  • Index(es):
    • Date
    • Thread