Re: ASCII
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>) |