Text Item Weirdness

This question is related to this post: http://bbs.applescript.net/viewtopic.php?id=15395

Some background:
I want to be able to represent a space character, in both text fields and table views, as another character. Originally I was using «data utxt25B4» (a small black triangle) for my space character representation. When getting the data from the table view that character would return as a “?” character. I couldn’t find a way to distinguish that from an actual question mark.

I have changed the space resprentation character to «data utxt02D0» (a triangle colon character). When I get the data from the table view this character shows up as “¢âˆž”.

The following code works in both Script Editor and Smile. It does not work in Xcode:

on snr(theString, searchString, replaceString)
	set {oTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {searchString}}
	set theString to theString's text items
	set AppleScript's text item delimiters to replaceString
	set theString to theString's text items as text
	set AppleScript's text item delimiters to oTID
	return theString
end snr

(*
theString = "¢âˆž¢âˆž"
searchString = "¢âˆž"
replaceString = " " --> a single space character
*)

-- this code has been adapted from code originally posted by jonn8. I made this code "less elegant" in hopes of making it work in this situation.

When this code is ran in Script Editor and Smile, like I said above, it works. When I run it in the Xcode debugger the line:

set theString to theString's text items

returns: {“¢âˆž¢âˆž”} instead of {“”, “”, “”} like it does in the other apps. mentioned. Any thoughts on how to resolve this?

Thanks in Advance,
Brad Bumgarner, CTA

Jacques,

Thanks for your reply. I, too, am OSX 10.4.3 and Xcode 2.2.

It doesn’t look like you are doing anything different as far as the “keyboard up” and “snr” handlers are concerned. Your code is pulling the data from a text field and I’m pulling the data from a table view. Looks like I need to investigate entry to and retrieval from the table view.

The problem hasn’t been solved, but it has been narrowed down. Thanks!

***** Follow-up *****
Thanks Jacques! The problem has been solved!

The changes I made were to get the data from the text fields as unicode text and use the defined space character (i.e.: «data utxt02D0» or SpaceChar) as the search string for the “snr” handler.

Now I can get the next hurdle (whatever that turns out to be :lol: )

Brad Bumgarner, CTA