RE: Converting Unix path to AppleScript path
RE: Converting Unix path to AppleScript path
- Subject: RE: Converting Unix path to AppleScript path
- From: Matt Deatherage <email@hidden>
- Date: Tue, 28 Mar 2006 17:43:27 -0600
On 3/28/06 at 3:20 PM, has <email@hidden> wrote:
> Ed Stockly wrote:
>
> > > <http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.10.htm>
> >
> > Matt, this is exactly what I needed, thanks a million!
>
> Note that the above linked code is wrong [1] - URLs are UTF8-encoded
> but those routines use your primary encoding (e.g. MacRoman), so if
> there's any non-ASCII characters in the URL you'll get an i
What you say is true, but I'm not sure it's worth the cost.
It is true that URLs are in UTF-8 encoding, but Ed's entire problem is
that the URLs he's reading from his XML file already have just about
every non-alphanumeric character already converted to "%XX" notation.
The old "decode_chars" routine would only fail if the original,
before-encoding path contained a non-ASCII character. If the
XML-writing program correctly encoded the hex characters from
ISO-Latin-1 or UTF-8, then for places where those characters differ,
decode_chars could return the wrong string.
But this will only happen for %XX values where XX > 0x80, and if
necessary, Ed can test for that in "decode_chars" and flag an error
condition. (Or he could cast the file to an alias and let AppleScript
throw the error if the file doesn't exist.) Or he can use Smile and
change "ASCII number" to "Unicode number", or he could even write the
raw byte to a temp file and read it back in as «class utf8».
I personally believe that any of these are faster and more efficient
than spawning an _entire shell and Python interpreter_ for decoding two
hexadecimal digits. I'm like that, though, and your mileage may vary.
--Matt
--
Matt Deatherage <email@hidden>
GCSF, Incorporated <http://www.macjournals.com>
The medicine's working. Please continue being purple.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden