• 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: Text and Offset Peculiarities ???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text and Offset Peculiarities ???


  • Subject: Re: Text and Offset Peculiarities ???
  • From: Ron Hunsinger <email@hidden>
  • Date: Sun, 15 May 2011 17:01:06 -0700


On May 15, 2011, at 2:22 PM, Michael D Mays wrote:
Is it possible that ASCII is just returning the low byte of a non printable multibyte character but offset is expecting all the bytes of the non printable character? 

All text in AppleScript is now actually Unicode text. (That wasn't always true; string, text and Unicode text used to be distinct types.) When you extract characters from text, you're getting Unicode characters, and all offsets and lengths are in terms of Unicode characters, not bytes.

The (now deprecated) ASCII number function returns the numeric equivalent according to the MacRoman encoding of the first character of its argument text, if that first character is in the MacRoman character set. If the first character is not MacRoman, it returns instead 63, which is the MacRoman (and ASCII and Unicode) code for a question mark. 

Note that ASCII, MacRoman, Latin-1, and Unicode all agree from 0 to 127. From 128 thru 255, ASCII is undefined, Latin-1 and Unicode agree with each other, but MacRoman is a whole 'nother thing. Only Unicode maps numbers 256 and up.

set apple to ASCII character 240
apple & " = " & (ASCII number of apple) & " in MacRoman, " & id of apple & " in Unicode"

returns

" = 240 in MacRoman, 63743 in Unicode"

Also note that those numbers (63 and 240 and 63743) are decimal, not hexadecimal.
Decimal 63 = hexadecimal 3F = '?'; decimal 99 = hexadecimal 63 = 'c'.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Text and Offset Peculiarities ??? (From: Michael D Mays <email@hidden>)
 >Re: Text and Offset Peculiarities ??? (From: Deivy Petrescu <email@hidden>)
 >Re: Text and Offset Peculiarities ??? (From: KOENIG Yvan <email@hidden>)
 >Re: Text and Offset Peculiarities ??? (From: Michael D Mays <email@hidden>)

  • Prev by Date: Re: Text and Offset Peculiarities ???
  • Next by Date: Re: Text and Offset Peculiarities ???
  • Previous by thread: Re: Text and Offset Peculiarities ???
  • Next by thread: Re: Text and Offset Peculiarities ???
  • Index(es):
    • Date
    • Thread