Modifying the item link copied to the clipboard

See Convert NSData into raw data string if you also need to convert AppleScript data into NS data.

-- Convert text to data
-- https://forum.latenightsw.com/t/convert-nsdata-into-raw-data-string/1914/4

use AppleScript version "2.4"
use framework "Foundation"
use scripting additions

set theText to "Hello World"
set theString to (current application's NSString's stringWithString:theText)
set theDataNS to theString's dataUsingEncoding:(current application's NSUTF8StringEncoding)
set theDataAS to my ASDataFromData:theDataNS
--> «data rdat48656C6C6F20576F726C64»

on ASDataFromData:theData
	set theCode to current application's NSHFSTypeCodeFromFileType("'rdat'")
	return (current application's NSAppleEventDescriptor's descriptorWithDescriptorType:theCode |data|:theData) as data
end ASDataFromData:
1 Like