Re: AppleScript with Japanese filenames
Re: AppleScript with Japanese filenames
- Subject: Re: AppleScript with Japanese filenames
- From: Christopher Nebel <email@hidden>
- Date: Wed, 25 Oct 2006 10:03:53 -0700
On Oct 25, 2006, at 3:02 AM, apparao wrote: I have a sample JPG file with name 新しいノート.jpg placed on Desktop. I want to send that file as a mail attachment to some body. For that i wrote the following script:
tell application "Mail" set newMessage to make new outgoing message tell newMessage set visible to true tell content make new attachment with properties {file name:"/Desktop/新しいノート.jpg"} end tell set subject to "新しいノート.jpg" end tell activate end tell
By using above script, mail app is activated and creating new compose window with out 新しいノート.jpg attachment.
English version is working fine and not with Japanese file names.
Am i doing any thing wrong in Apple script (or) Is Apple script, not supports Japanese filenames?
The problem isn't with the file name as such -- AppleScript can deal fine with files with whatever name you like, though you may need to be careful to say "as Unicode text" instead of "as string". (My usual advice is to not use "as" unless you actually have to.)
The problem is with the text constant "新しいノート" -- because of how AppleScript compiles its scripts, that only stays "新しいノート" as long as your primary language (as set in the International preference pane) is Japanese; otherwise you get gibberish. Depending on how your formatting preferences are set, it may or may not look right when you compile it.
I'd echo Mr. Waibel's advice -- make the script ask for the file to attach. (Or make it an application and put this in the "on open" handler, or make it get the Finder selection. The point is to somehow get the file from the user instead of hard-coding it into the script.) That way, you avoid the text-constant encoding problem, and you have a more general script.
--Chris Nebel AppleScript Engineering
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden