Bug report: Title case fails after smart apostrophe

For a locale-sensitive alternative, if you bind a KM variable with a name like itcHeadline to the string, (for example from the clipboard), you can use this:

JavaScript for Automation source text:

$(Application('Keyboard Maestro Engine').getvariable('itcHeadline'))
    .capitalizedStringWithLocale($.NSLocale.currentLocale).js

( See Improved Title Case Macro )

or in AppleScript (through which access to the Foundation classes is unfortunately more circuitous)

use framework "Foundation"
use scripting additions

tell application "Keyboard Maestro Engine"
    set strText to getvariable ("itcHeadline")
end tell

((current application's NSString's stringWithString:(strText))'s ¬
        capitalizedStringWithLocale_(¬
        (current application's NSLocale's currentLocale()))) as text
2 Likes