Re: System Events "Show Clipboard" Bug?
Re: System Events "Show Clipboard" Bug?
- Subject: Re: System Events "Show Clipboard" Bug?
- From: Christopher Nebel <email@hidden>
- Date: Fri, 18 Jul 2003 17:49:37 -0700
At 6:49 pm -0400 18/7/03, Jonathan Levi, M.D. wrote:
Good point: the clipboard should be able to recognize Unicode. I'll
send a bug report to Apple.
Please do. Note that if the clipboard also has a plain text flavor
(see below), that's what you'll see. Because of the limits of plain
text, this may not match the Unicode text.
On Friday, July 18, 2003, at 4:39 PM, John Delacour wrote:
1. Run this script and you will see that it is impossible to get
anything but a list of a Unicode character onto the clipboard.
[ <> = lozenge character ]
set _filename to (ASCII character 215) as Unicode text
--> "<>"
set the clipboard to _filename
the clipboard
--> {"<>"}
set _reco to the clipboard as record
-->{Unicode text:"<>"}
set _utext to Unicode text of _reco
--> "<>"
set the clipboard to _utext
the clipboard
--> {"<>"}
There is no difficulty if you change 215 to 115 or anything up to 127
-- ie the US-ASCII range.
Interesting. It seems PutScrap is being clever. (And the clipboard
commands are being stupid, but that doesn't surprise me.)
First you have to understand that the clipboard can contain multiple
"flavors" of whatever it was you copied. For instance, when you copy
an item in the Finder, it puts both the icon and the name on the
clipboard. (More on this in #2.)
Second, the AppleScript clipboard commands handle plain text specially
-- if that's one of the flavors, that's what they'll return.
Otherwise, you get all the flavors as a record. (You can force this
behavior by saying "the clipboard as record".) The stupid bit is that
they don't extend this special treatment to Unicode text, and they
should. As it happens, we've just been fixing some other stuff in
there, so I'll see if we can fix this too.
The interesting bit is that when you ask to set the clipboard to a bit
of Unicode text, the PutScrap routine (which is the business end of
"set the clipboard") apparently gets clever, and if the string is all
ASCII, then it adds *two* flavors, one Unicode and one plain text,
instead of just the Unicode.
2. Name a file "<>" (lozenge) and copy it. Then do "Show Clipboard"
and you will see the lozenge. Even with "inconvertible" Unicode, you
will see the Unicode text, though it cannot be properly displayed in
Geneva.
The Finder is cheating a bit. When you copy an item, it actually puts
four flavors on the clipboard: one PICT, one icns, one Unicode text,
*and one plain text.* If the Unicode text can be converted to the
primary encoding, as it can for a lozenge, it looks like everything
works. If you try something harder like Hebrew or polytonic Greek,
you'll get garbage.
--Chris Nebel
Apple Development Tools
_______________________________________________
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.