• 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: Loukas Kalenderidis <email@hidden>
  • Date: Wed, 17 Sep 2003 17:17:16 +1000

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
----

Loukas Kalenderidis
Angier Consulting Pty Ltd
_______________________________________________
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.

References: 
 >Hex > Text (From: Rob Jorgensen <email@hidden>)

  • Prev by Date: Re: Click and Drag using UI scripting?
  • Next by Date: Re: XML parse
  • Previous by thread: AS in AppleExpo Paris.
  • Next by thread: Re: Hex > Text
  • Index(es):
    • Date
    • Thread