Re: Hex > Text
Re: Hex > Text
- Subject: Re: Hex > Text
- From: Rob Jorgensen <email@hidden>
- Date: Wed, 17 Sep 2003 07:26:50 -0400
At 5:17 PM +1000 9/17/03, Loukas Kalenderidis wrote:
Hi,
To extract the resource from the file you could use DeRez (part of
the developer tools) as follows:
$ /Developer/Tools/DeRez -only drag foo.textClipping |sed -e
's/^[^\"]*\"\([^\"]*\)\".*$/\1/'|grep -v "data"|grep -v "};"|sed 's/
//g'|tr -d '\n'
as a `do shell script' from AS (appropriately/horribly escaped):
do shell script "/Developer/Tools/DeRez -only drag
~/Desktop/foo.textClipping |sed -e
's/^[^\\\"]*\"\\([^\\\"]*\\)\\\".*$/\\1/'|grep -v \"data\"|grep -v
\"};\"|sed 's/ //g'|tr -d '\n'"
And to convert to text, pipe the output of the last command to:
sed 's/\(..\)/0x\1 /g'|tr ' ' '\n' |xargs printf "%d\n"|perl -e
'while(<>){printf("%c",$_)}'
AS version:
do shell script "echo " & theHex & "|sed 's/\\(..\\)/0x\\1 /g'|tr '
' '\\n'|xargs printf \"%d\\n\"|perl -e
'while(<>){printf(\"%c\",$_)}'"
(where theHex is the output from the last command)
That said, i can't see how converting a `drag' resource to text is
of any use since its a binary resource and not a very interesting
one at that. The text data for a clipping is located in the TEXT
resource. Anyway, hope this helps.
Loukas,
The only reason that I've converted the drag resource to hex is for
the sake of portability. Most likely this is due to my ignorance. I
won't pretend to know much about resources but when the text version
of the resource is pasted into a script and then compiled, it
behaves strangely compared to other text, even though it appears to
remain intact. My lack of understanding of this behavior causes me to
want to store it within the script as hex and then convert it when
needed to make a clipping file.
Thank you very much for the code! I doubt that I'll ever grok it but
I'll gladly use it. :-)
Best regards,
Rob
_______________________________________________
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.