Path encoding to use with AppleScript

seb2

Registered
Hi everybody,

I have written a small Cocoa app that needs to communicate with AppleScript through an NSTask. (Or, to be more specific, an NSTask with "/usr/bin/osascript" as launchPath)

If the filename is 7-bit-ASCII-"clean", everything works fine. But as soon as I'm dealing with filenames with umlauts or other "fancy" characters in them, it just doesn't want them.

Anybody have a clue?
 
Sorry, yes, I could have been more specific. ;-)

I get an error -10006, Apple Event Registry "Can't set to" -- Probably it can't "find" the file I'm referring to. In the end, with files without special characters in them, it works, so I figured that it cannot set the file because it cannot find them. Due to the wrong encoding...

Does that make sense? If yes, what do I do. The file names can change all the time (in fact, I let the user choose), so that's not an option.

Any ideas?
 
OK, I just thought I could give an example...

When I want osascript to do something to the file /Users/sjobs/earnings.txt, I pass :Users:sjobs:earnings.txt as path to osascript. Well, embedded in some instructions which are the argument for the NSTask. But that works, so that's not the point.

But how do I encode the path when the filename is /Users/chirac/Été_en_France.jpg? The pattern, of course, is similar to the other example, but osascript needs the accented characters to be encoded in some way. It can't seem to handle the default NSString encoding (Which AFAIK is Unicode).

Please...
 
OK, nobody?

In another thread, whitesaint had asked me for the source code which I sent him, so why not let you see my problem...

The source is here: http://www.uni-hildesheim.de/~skra0063/YAD.sit
"YAD" is the best I could come up with for "Yet another desktop (utility/tool/whatever)"
Don't be surprised by the funny way I construct the menu, I thought about also letting it have a Dock menu, so that's why. (I know that there's a bit more to Dock menus, I've used them before. I didn't want to tackle that before having solved the encoding problem.)

Try selecting an image with 7 bit clean ASCII characters; everything's fine. Now choose an image with an umlaut or accented character in its name. No go.

Any ideas?
 
Back
Top