• 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: KOENIG Yvan <email@hidden>
  • Date: Sun, 15 May 2011 22:28:35 +0200


Le 15 mai 2011 à 22:05, Michael D Mays a écrit :


I am really missing the point or you guys are.:)

I find the location of a string with offset
I take that location and decrement it by 1
I use ASCII to tell me what that character is
I concatenate ASCII's results before the string which was initially found
Offset says it cannot find that string.


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?

I wrote a handler

tell application "Safari"
set myText to the text of document 1
set myOffset to offset of " Departing " in myText
end tell
tell application "TextEdit"
set tt to ""
set lowerLimit to myOffset - 10
set upperLimit to myOffset + 10
repeat with i from lowerLimit to upperLimit
set tt to tt & i & " " & (text i of myText) & (ASCII number (text i of myText)) & "\n" as text
end repeat
set ttt to text lowerLimit thru upperLimit of myText
set the text of document 1 to tt & "\n\n\n" & ttt
end tell


with the following text

1944   p112
1945    32
1946   O79
1947   n110
1948   l108
1949   y121
1950
10
1951
10
1952
10
1953   63
1954    32
1955   D68
1956   e101
1957   p112
1958   a97
1959   r114
1960   t116
1961   i105
1962   n110
1963   g103
1964    32



p Only


Departing

After the three returns (1950-1952) there is a non-printable character at 1953. ASCCII is returning only 'part' of it. That part isn't sufficient for offset to match it.

The character whose ASCII is 63 isn't a non printable exotic character, it's the letter "c"
The character whose ASCII code is 32 is the space.


Why are you using ASCII which is fooled by Unicode characters ?

Apple carefully delivered it's successor s:
ASCII character --> character ID
ASCII number --> ID

Yvan KOENIG (VALLAURIS, France) 15 mai 2011 22:28:20



_______________________________________________
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
  • Follow-Ups:
    • Re: Text and Offset Peculiarities ???
      • From: Michael D Mays <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>)

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