• 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: Nir Soffer <email@hidden>
  • Date: Thu, 24 Aug 2006 14:09:13 +0300

You can just send the unicode string as is, It seems that NSTask is doing the right thing with it.

    NSArray *args = [NSArray arrayWithObjects:
        @"-l",
        @"-v",
        [NSString stringWithUTF8String:"/Path/To/שלום"], nil];

    [NSTask launchedTaskWithLaunchPath:@"/bin/ls" arguments:args];


On Aug 22, 2006, at 8:04 PM, Martin wrote:

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


Best Regards,

Nir Soffer

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

  • Prev by Date: NSView subclasses with IB
  • Next by Date: Re: NSView subclasses with IB
  • Previous by thread: Re: Non-ASCII NSTask arguments
  • Next by thread: Re: Non-ASCII NSTask arguments
  • Index(es):
    • Date
    • Thread