Re: Text and Offset Peculiarities ???
Re: Text and Offset Peculiarities ???
- Subject: Re: Text and Offset Peculiarities ???
- From: Michael D Mays <email@hidden>
- Date: Sun, 15 May 2011 16:22:49 -0500
Ascii 63 is "?" not "c".
Okay I am an old fart. I just need to do this tell application "Safari" set myText to the text of document 1 set myOffset to offset of " Departing " in myText set myFunnyChar to text (myOffset - 1) of myText as text set mySearchForText to myFunnyChar & " Departing" as text set myOffset to offset of mySearchForText in myText get the id of mySearchForText end tell
The offender is 65532 OBJECT REPLACEMENT CHARACTER. Thanks for the pointer.;)
Michael
On May 15, 2011, at 3:28 PM, KOENIG Yvan wrote: 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