• 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: Ignoring Smart Quotes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ignoring Smart Quotes


  • Subject: Re: Ignoring Smart Quotes
  • From: has <email@hidden>
  • Date: Thu, 2 Oct 2008 22:37:22 +0100

Simon Topliss wrote:

I was hoping that 'ingoring
" something would let me evaluate text
that contains smart quotes against regular hyphens would let me test
to equality of a Unicode text string.

However, this code evaluates to false.

set t1 to "Apple's" -- regular hyphen (ASCII #39 Unicode 0027)
set t2 to "Apple’’s" -- U+2019 (8217)

ignoring punctuation and diacriticals
	t1 = t2
end ignoring

Does anyone have any code snippets that would help or recommend
another approach.

Normalise the strings yourself before comparing them (this is what 'ignoring' blocks do under the hood), e.g.:


on straightenQuotes(str)
	repeat with pattsRef in {{"[“”]", "\""}, {"[‘’]", "'"}}
		set {findPatt, newStr} to pattsRef
		tell application "TextCommands"
			set str to search str for findPatt replacing with newStr with regex
		end tell
	end repeat
	return str
end straightenQuotes


straightenQuotes("Apple's") = straightenQuotes("Apple’’s) --> true

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________
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
  • Prev by Date: Re: AppleScript broken in 10.5.4
  • Next by Date: Invoke Unix Tool in Script Application Bundle
  • Previous by thread: Re: Ignoring Smart Quotes
  • Next by thread: Invoke Unix Tool in Script Application Bundle
  • Index(es):
    • Date
    • Thread