Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Jolly Roger Newsgroups: comp.sys.mac.system,alt.comp.lang.applescript Subject: Re: Searching for "fraction slash" Followup-To: alt.comp.lang.applescript Date: 20 Mar 2015 13:48:42 GMT Organization: People for the Ethical Treatment of Pirates Lines: 62 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net vPfkQ40tVkFY0j5/88NJlw45OLwHXJBve6fTngAXdYrgBay+xw Cancel-Lock: sha1:mF4rtOdEiUoozKST39m0ELOmS2A= X-Face: _.g>n!a$f3/H3jA]>9pN55*5<`}Tud57>1Y%b|b-Y~()~\t,LZ3e up1/bO{=-) User-Agent: slrn/1.0.1 (Darwin) Xref: csiph.com comp.sys.mac.system:71673 On 2015-03-20, isw wrote: [Followups set to alt.comp.lang.applescript] > I opened one of the recipes with a hex editor, and found that the > location of the slash contains "\u8260 ". A search revealed that is > "&frasl" in HTML, which is evidently a "fraction slash". The Mac's > Character Viewer thinks that "fraction slash" is U+0066, for what that > is worth. 8260 decimal is 2044 hexadecimal. In AppleScript, you can use the «data utxt» formatter to work with Unicode characters. To get the fraction slash character, you can use: «data utxt2044» as Unicode text > So all I want to do is find the thing so it can be replaced by a > "regular" slash, but I need to know what to tell the AppleScript to look > for, and I don't know how to do that. This seems to work for me: -- begin script property bunchOfText : "this ⁄ is a test of the emergency ⁄ broadcast system please stay ⁄ calm and bring ⁄ your towel" property searchCharacter : «data utxt2044» as Unicode text set newText to my SearchReplace(bunchOfText, searchCharacter, "/") return my SearchReplace(newText, searchCharacter, "***") on SearchReplace(sourceStr, searchString, replaceString) -- replace with in set searchStr to (searchString as text) set replaceStr to (replaceString as text) set sourceStr to (sourceStr as text) set saveDelims to AppleScript's text item delimiters set AppleScript's text item delimiters to (searchString) set theList to (every text item of sourceStr) set AppleScript's text item delimiters to (replaceString) set theString to theList as string set AppleScript's text item delimiters to saveDelims return theString end SearchReplace -- end script The "bunchOfText" property is a string with the Unicode 2044 characters in it (added directly from the keyboard by typing Option-Shift-1. I used the «data utxt» formatter to set the "searchCharacter" property to the single Unicode 2044 character so I can search for it. I typed the « and » characters on the keyboard with Option-\ and Option-Shift-\, respectively. The SearchReplace handler uses an AppleScript text item delimiter trick to locate the substring and replace it. -- E-mail sent to this address may be devoured by my ravenous SPAM filter. I often ignore posts from Google. Use a real news client instead. JR