Re: Getting Info from the Finder
Re: Getting Info from the Finder
- Subject: Re: Getting Info from the Finder
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 19 May 2010 11:42:24 -0400
On Wed, May 19, 2010 at 11:09 AM, Thomas Fischer <email@hidden> wrote:
> Hi Mark,
> I didn't find any way to evaluate \U00A9 directly, but at least I can
> convert from hex number X to decimal number Z using
> do shell script ("printf \"%d\" 0x" & X)
> Unfortunately, printf seams to be completely unaware not only of Unicode,
> but of any characters beyond ASCII 127:
> e.g.
> printf "%b" "\x7e" -> ~
> but
> printf "%b" "\xe4" -> ?
Well, that outputs exactly what you asked for - the one-byte value
0xe4. Which would work if you were using a one-byte character set
like Latin-1 or MacRoman. But for Unicode it doesn't work.
Python Unicode strings (u'...') understand the \u syntax, so they work
well here, e.g.:
set myString to someStringReturnedFromMdLS
do shell script "python <<EOF" & linefeed & "print u" & quoted form of
myString & ".encode('utf-8')"
(You'll have to manually set linefeed to ascii character 10 on
pre-Leopard systems).
--
Mark J. Reed <email@hidden>
_______________________________________________
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/archives/applescript-users
This email sent to email@hidden