• 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: ASCII
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ASCII


  • Subject: Re: ASCII
  • From: Emmanuel <email@hidden>
  • Date: Fri, 19 Jan 2001 00:17:02 +0100

At 23:44 +0100 18/01/01, Arthur J Knapp wrote:
>> Is there a command to convert to hex? I know how to make a script for
>>it, but
>> a single command would be easier
>
> Here is my rather interesting way to do it. Most of the
>time, it would be a bit silly to use it, but I suspect that
>if you have a really BIG string to convert, this may be one
>of the fastest vanilla solutions around, despite the amount
>of code involved:
>
>
>to hexify_via_file(str)
>
> -- Create a temporary file
> [...]
> --
> --> +data rdat416243644566476849;
>> [...]

For a short string, when it comes to make it into +data xxxxHHHHHHHH;, it
may be faster not to use a file:

--------------------------------
set theString to "Yes."
set theData to theString as C string -- no good if the data contains ASCII 0
-- +data cstr5965732E00; -- chop off last byte, it's 0
--------------------------------

--------------------------------
set theString to "Yes."
set theData to theString as Pascal string -- no good if the length > 255
-- +data pstr045965732E; -- drop first byte, it's the length
--------------------------------

HTH

Emmanuel


References: 
 >Re: ASCII (From: "Arthur J Knapp" <email@hidden>)

  • Prev by Date: Re: OSAX within tells
  • Next by Date: Re: Toggle shared status of files?
  • Previous by thread: Re: ASCII
  • Next by thread: Re: ASCII
  • Index(es):
    • Date
    • Thread