Re: Re: Stupid, Stupid Text Features [Was: Can't set creator type]
Re: Re: Stupid, Stupid Text Features [Was: Can't set creator type]
- Subject: Re: Re: Stupid, Stupid Text Features [Was: Can't set creator type]
- From: Hanaan Rosenthal <email@hidden>
- Date: Tue, 24 Feb 2004 8:53:25 -0500
- Organization: Custom Flow Solutions
Hi,
(USEFUL HANDLER AT END)
What we're looking at here is AppleScript in transition, following OS X's move
to Unicode as the standard string format.
It will take a concentrated effort on the AppleScript dev team's behalf to make
sure that (at least) all AppleScript and standard additions either always use
Unicode and understand Unicode, or can understand the three text formats
that appear to be in use almost arbitrarily (Unicode, 8-bit string and styled
text).
What I'm irritated by the most is the resurgence of styled text in statement
results. I get it returned from commands that have nothing to do with any
style, and I don't know of many commands that require styled text as param.
What we need is that whenever anyone finds an issue like that, make sure to
report the bug to Apple.
We will get there eventually, but in the meanwhile, here's a handler everyone
should have in their arsenal.
Pass any string to it: styled, Unicode or plain string and it will return a plain
string back.
on get_plain_string(theText)
set theText to (theText as Unicode text) as string
try
set theText to +class ktxt; of (theText as record)
end try
return theText
end get_plain_string
Hanaan
>
>
At 10:46 +0000 02/24/2004, Mr Tea wrought:
>
>
>In the original thread, I reported a problem in Panther when using the
>
>text returned from a dialog to set the creator type or file type of a
>
>file. Basically, it can't be done without first performing a really
>
>hairy coercion.
>
>...
>
>Aside from setting creator and file types, are there any other places
>
>where this gotcha is likely to strike?
>
______________________________________________________________________
>
>
I'm with Nick on this one.
>
>
AppleScript's inability to directly coerce to plain text is quite beyond
>
belief. The fact that there are places where plain text is still
>
*required* makes the inability even less palatable.
>
>
"set theCode to <<class ktxt>> of (text returned of dRes) as record"
>
>
It's fortunate the above method exists. It is ridiculously
>
overcomplicated for the task, and as far as I know it isn't documented
>
anywhere except in some list-archives.
>
>
I posted about this a couple of months ago and had intended to raise a
>
ruckus. Unfortunately time went by, and I forgot to do so.
>
>
Thanks. Nick.
>
>
>
Chris
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/
applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.