RE: Evaluating Double Byte
RE: Evaluating Double Byte
- Subject: RE: Evaluating Double Byte
- From: Scott Babcock <email@hidden>
- Date: Wed, 6 Feb 2008 11:14:15 -0800
- Acceptlanguage: en-US
- Thread-topic: Evaluating Double Byte
I have a few questions that may help to clarify your situation:
Where is the data for your strings coming from? How are you converting the extended characters to the raw Unicode ("data utxt") format? How are you determining that the fault lies in NSAppleScript? Do you get an error, or do you just get the wrong result?
I have scripts that I have to run clear back on Jaguar. There's a bug in Jaguar AppleScript that causes it to crash when I refer to raw Unicode text data, so I always use 'do shell script' and Perl to define my Unicode strings. Here's that it looks like:
set NunavikHi to do shell script "perl -e 'use utf8; print chr(0x1575);'"
set theText to ("pulled text " as Unicode text) & NunavikHi & " from db"
insert text theText at text object of selection
Note the Unicode text coercion of the first component of the string. If you're running at least AppleScript 1.10 (shipped with Mac OS 10.4), this isn't strictly necessary. If you're running on a prior version of AppleScript, this is critical. The reason is that the data type of the result of string concatenation would be the data type of the initial concatenated element. Each succeeding element would be automatically coerced to this type. If the initial data type was [string], errors or silent data loss could occur when [Unicode text] elements were downcast to [string].
-----Original Message-----
Date: Tue, 5 Feb 2008 16:47:52 -0500
From: "Mark J. Reed" <email@hidden>
Subject: Re: Evaluating Double Byte
To: email@hidden, has <email@hidden>,
"Applescript Users" <email@hidden>
Message-ID:
<email@hidden>
Content-Type: text/plain; charset=UTF-8
Why are you generating AppleScript source code? Just write the script
separately, design it to take the text to insert as a parameter, and
run it from your app. There's rarely a good reason to spit out new
code dynamically like this...
On 2/5/08, email@hidden <email@hidden> wrote:
>
>
> has <email@hidden> wrote: On 5 Feb 2008, at 20:42, wrote:
>
> > Does anybody know of a means to evaluate a double byte character
> > without using the chevron notation i.e.:
> >
> > ??data utxt1603??
>
> Depends what you mean by "double byte character". Hex string? unichar?
> Sounds like you're trying to do code generation of some sort, which
> for most problems is the wrong solution anyway. More information would
> be helpful.
>
> has
> --
> http://appscript.sourceforge.net
> http://rb-appscript.rubyforge.org
>
> Sure, I am using my main application to pull data to be inserted in a Word
> Document.
>
> thus pulling dynamic text in insert into preformed applescript code i.e.
>
> insert text "pulled text from db here" at text object of selection
>
> This works fine until I come across any Japanese, Chinese, ect. languages,
> which I can test if they are and then wrap them in code such as:
>
> insert text "pulled text " & ??data utxt1575?? as Unicode text & "from db
> here" at text object of selection
>
> however, when the NSApplescript event attempts to pass that to applescript,
> it seems to not recognize the chevrons. It will replace them with what
> looks like a different character.
>
> not sure if this was what you were looking for (nor if I made a lot of sense
> for that matter ;) ), but it seems I need to find a way to pass the string
> to applescript without using the chevrons.
>
> Thanks for looking at it!
>
> Brian
>
> Works fine and dandy with low ASCII, or pre 2004 word, but wh
>
--
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