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

Re: Hex String Handlers


  • Subject: Re: Hex String Handlers
  • From: Paul Berkowitz <email@hidden>
  • Date: Tue, 31 Dec 2002 08:48:47 -0800

On 12/31/02 8:18 AM, "Arthur J. Knapp" <email@hidden> wrote:

> It has recently been brought to my attention that some versions
> of AppleScript are not going to behave as I would expect them to
> in the above. It is safer to explictly coerce the "c" from the
> "c in s" statment to a string before assigning it to the text
> item delimiters:
>
> repeat with c in s
> set AppleScript's text item delimiters to (c as string)

Or maybe even the official:

set AppleScript's text item delimiters to {c as string} -- list

<snip>

>> set str to "abc"
>>
>> try
>> err of (str as Pascal string)
>> on error m
>> end try
>> m's text from -((str's length) * 2 + 2) to -3 --> "616263"
>
> I neglicted to mention a very obvious limitation of the above,
> namely, that a Pascal string can only contain 255 characters of
> text, so:
>
> on StringToHex(s)
>
> set c to s as C string
>
> try
> err of c
> on error msg
> end try
>
> return msg's text -((s's length) * 2 + 4) thru -5
>
> end
>
> I would appreciate any feed back from users of OSX as to whether
> or not this StringToHex() handler works for them, thank you.

Yes, it does, so far. But if the "string" that starts it off was picked up
somewhere and is actually Unicode, you might want to use your own AsText()
handler on it first to be safe:

on AsText(str) --Arthur Knapp's
--corece Unicode or other text to styled string to plain text
try
return (((str as string) as record)'s +class ktxt;)
end try
return str -- if plain text to begin with

end AsText


--
Paul Berkowitz
_______________________________________________
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: 
 >Re: Hex String Handlers (From: "Arthur J. Knapp" <email@hidden>)

  • Prev by Date: Re: Hex String Handlers
  • Next by Date: GUI Scripting of Mail Preferences
  • Previous by thread: Re: Hex String Handlers
  • Next by thread: Recordable Applications
  • Index(es):
    • Date
    • Thread