Set data as specific class to clipboard

Hi,

I want to set the clipboard to text data as specific type/class. This is for sharing data between apps. And works like this:

set theClass to «class TEST» --the class name is irrelavant
set theClip to "This is a test string"
set the clipboard to {class:theClass, data:(theClip)}

Now the clipboard contains this data:

But it shut be:

without any dots and the prefix: dle2…TEST…>…rdatutxt…*.

You can analyze the clipboard with the app “Clipboard Viewer.app”. You find it on your HD /Developer/Applications/Utilities.

One thing may be the character encoding - the clipboard represents the data in utf-16 (2 Bits) and not in ascii (1 Bit)? Is this the reason for the dots?
Is there any possibility to manipulate the clipboard in my way? Or is shell command “pbcopy” a solution?

Regards,
finder

AppleScript: 2.2.1
Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)

Hi,

everything is correct, a literal string in AppleScript 2 is always UTF16, so your variable theClip contains UTF16
and this is copied to the clipboard.
Try


set theClass to «class TEST» --the class name is irrelavant
set theClip to "This is a test string"
set the clipboard to {class:theClass, data:(theClip)}
get the clipboard as record

and look into the result window

Stefan, thanks for the reply!

You are right, the clip is encoded as utf-16. But I need an ascii encoded clip!

May be that Applescript Studio gives me applicable access to the clipboard?!

Has anybody a hint?

Regards,
finder.