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

Non-ASCII NSTask arguments


  • Subject: Non-ASCII NSTask arguments
  • From: Martin <email@hidden>
  • Date: Tue, 22 Aug 2006 19:04:00 +0200

Hi,

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]]];


Thanks for you help,
Martin.
_______________________________________________
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


  • Follow-Ups:
    • Re: Non-ASCII NSTask arguments
      • From: Nir Soffer <email@hidden>
    • Re: Non-ASCII NSTask arguments
      • From: Steve Christensen <email@hidden>
    • Re: Non-ASCII NSTask arguments
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Re: Rotating an object
  • Next by Date: Re: Undocumented AB property 'com.apple.speech.ABSpeakable'?
  • Previous by thread: Re: Crash in -[NSString(NSStringDrawing) drawInRect:withAttributes:] on 10.3.9
  • Next by thread: Re: Non-ASCII NSTask arguments
  • Index(es):
    • Date
    • Thread