Be careful of “Smart Punctuation”
1 min readOct 22, 2018
You might have known that since iOS 11, Apple has a feature called “Smart Punctuation” which has few “smart” behaviors like:
- Automatically replace quotation mark like `U+0022` to whatever quotation marks in your language like `U+201C`.
- Automatically replace double hyphen `U+002D` to a em-dash `U+2014`
- Automatically insert an extra space after a paste operation or delete one or two spaces after a cut or delete operation.
Users can of course disable these features in Settings app.
Programmatically you can also disable them by setting :
someTextInput.smartQuotesType = .no
someTextInput.smartDashesType = .no
someTextInput.smartInsertDeleteType = .no
(Both TextField and TextView conform to `UITextInputTraits`)
So the unexpected part is, even if you set these properties for your input, you would still see “Smart Punctuation” happens when you call API like:
UITextView.replace(_ range: UITextRange, withText text: String)
Too smart … I would say.