问题
Our app accepts user text input which we then save to a server-side database. In iOS 11 when you enter two "-" characters in a row they are automatically combined into an emdash (—). When you enter three "-" characters in a row you end up with an emdash + a half emdash which has an invalid terminator. This is causing issues for my rails server which cannot parse this string because it is invalid. The string looks like this: \xE2\x80\x94\x00
回答1:
'Smart dashes' as it is called, is the process is converting two/three dashes to a single larger dash. This is only available from iOS 11. It can be controlled using smartDashesType which is a part of the UITextInputTraits protocol.
来源:https://stackoverflow.com/questions/47022956/in-ios-11-the-keyboard-autocorrect-creates-invalid-utf8