the clipboard as unicode text NOT
the clipboard as unicode text NOT
- Subject: the clipboard as unicode text NOT
- From: John Delacour <email@hidden>
- Date: Fri, 9 May 2003 14:26:57 +0100
- Mac-eudora-version: 6.0a16
I've finally worked out what have been breaking some scripts I have
been working with this week.
I may be missing something, but I don't think so.
When you say 'get the clipboard as unicode text' you would expect to
get the contents of the clipboard as unicode text, but that's not
what happens. A single character on the clipboard can only be got as
unicode text if it is in the range up to U-00FF.
I use the Apple character as an example in the following
demonstration. Any character that does not exist in "Unicode Latin
1" (roughly speaking) will produce the meaningless Out of Memory
error.
I guess this ought to be common knowlege, but I didn't know it. I'm
now trying to work round it with pbpaste but haven't quite worked it
out yet...
(*
set the clipboard to (ASCII character 240)
do shell script "pbpaste"
--> "Can't make some data into the expected type."
*)
Here's the demo:
set apple to ASCII character 240
set dd to display dialog "
Get " & apple & " from...
" buttons {"Cancel", "Clipboard", "Text of document"}
set choice to button returned of dd
if choice is "Text of document" then
tell application "TextEdit"
make document at end
set text of document 1 to apple
set s to text of document 1
close document 1 saving no
class of s -->Unicode text
end tell
else
set the clipboard to apple
set s to get the clipboard as Unicode text
class of s
--> string
end if
try
set fU to "/tmp/temp"
set f to fU as POSIX file
try
close access f
end try
open for access f with write permission
set eof f to 0
write s to f as <<class utf8>> --
close access f
set t to read f
on error e
set t to e
end try
display dialog "
" & apple & " as UTF-8 = " & t
_______________________________________________
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.