Referring to characters in text

How does one refer to characters in text? The old ASCII commands have been deprecated and the method now is to use the id property.


set theText to "ABCDEFG" as text
set theFirstID to id of item 1 of theText
--result is 65 but is integer 65 or string 65?
set theID to id of theText
--result is list of 7 items like above
type of item 1 of theID
--can't get type

Is this result Unicode “A”? Is id a text item property? Is id a string value, int value or some special unicode data type? Can’t seem to get type of these ids.

Thanks for any insights.

Hi,

from the AppleScript Release Notes: 10.5 Changes

text objects have an id property, which may also be used as an address.
These allow mapping between Unicode code point values and the characters at those code points: for example, id of “A” returns 65, and character id 65 returns “A”. The id of text longer than one code point is a list of integers, and vice versa: for example, id of “hello” returns {104, 101, 108, 108, 111}, and string id {104, 101, 108, 108, 111} returns “hello”. (Because of a bug, text id … does not work; you must use one of string, Unicode text, or character.) These obsolete the older ASCII character and ASCII number commands, since, unlike those, they cover the full Unicode character range and will return the same results regardless of the user’s language preferences.

Thanks Stefan! What is meant by “text objects have an id property, which may also be used as an address?”
What kind of reference would it apply to? Is it simply that “character” in turn is a property of “id”. So if 65 is an address then A would be the unicode “resident?”

65 is just an integer


class of id of "A" --> integer

Thanks.