• 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: Non-ASCII NSTask arguments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non-ASCII NSTask arguments


  • Subject: Re: Non-ASCII NSTask arguments
  • From: Steve Christensen <email@hidden>
  • Date: Tue, 22 Aug 2006 11:43:29 -0700

On Aug 22, 2006, at 10:04 AM, Martin wrote:

How am I supposed to create and launch an NSTask when one of its arguments is a file path containing non-ASCII characters ?

The follwing code doesn't work (du says the file doesn't exist)
- (IBAction)test:(id)sender
{
		NSTask *aTask = [[NSTask alloc] init];
		NSMutableArray *args = [NSMutableArray array];

		[args addObject:@"/Users/martin/éàùç.txt"];
		[aTask setLaunchPath:@"/usr/bin/du"];
		[aTask setArguments:args];
		[aTask launch];
}

I've tried many different things and made numerous tests (using NSString stringWith..., logging the result with fileSystemRepresentation, etc...) and the only thing that works is :
[args addObject:[NSString stringWithUTF8String:"/Users/martin/ éàùç.txt"]];


Ok, that works if I actually hard-type the file path in my source code. But the file path I already have is a NSString coming from a drag & drop operation. But unfortunately, the following code doesn't work !
[args addObject:[NSString stringWithUTF8String:[myFilePath UTF8String]]];

You said above, "the file path I already have is a NSString coming from a drag & drop operation." So why don't you just use the string as-is?


    [args addObject:myFilePath]?

Your code is taking the unicode drag & drop string, converting it to utf8, and passing that back in to create a new unicode string. That seems a bit roundabout, unless I'm misunderstanding something.

steve

_______________________________________________
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: 
 >Non-ASCII NSTask arguments (From: Martin <email@hidden>)

  • Prev by Date: Re: how to create a plugin from a bundle
  • Next by Date: core data approach to multi-column data?
  • Previous by thread: Re: Non-ASCII NSTask arguments
  • Next by thread: Re: Non-ASCII NSTask arguments
  • Index(es):
    • Date
    • Thread