• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Hex > Text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Hex > Text
  • Next by Date: Re: Folder action dies
  • Previous by thread: Re: Hex > Text
  • Next by thread: Re: Hex > Text
  • Index(es):
    • Date
    • Thread