Apple moves the cursor when changing a plain to curly quote

Something to try for fun!

I was editing some text in a Xojo TextArea and the resulting text was not what I had typed. I tried it again, with the same results. I tried it again in a default RTF TextEdit document (doesn’t work in Plain Text) and it did the same, so it is an Apple bug.

Here is the original text:
MyField = '2022-01-01'

What I want is:
MyField = '2022-01-01 00:00:00'

What happens:
After the space and first zero, Apple decides my plain quote character needs to become a right-curly-quote, and replaces it, but leaves the cursor now AFTER the curly-quote, not before, so the text becomes (note the new curly-quote):
MyField = '2022-01-01 0’0:00:00

I am on a Monterey beta, but I expect it is an old bug.

Turn off “Use smart quotes and dashes” in Keyboard preferences to stop the system from messing up your code.

Screen Shot 2022-01-12 at 8.33.32 AM

Well, this would work for you, but if your user hasn’t done the same, it’s a problem. Also always check/replace smart quotes in user input (e.g. if you need clean code) in case they haven’t turned it off…

I think that really depends on intention. For code, I agree. For general inputs, probably not.

Set your macOS language to French and do the same with "… it will be replaced with “« " (note the space after the « sign) or " »”… the space is certainly a non breaking space (per grammar rules, not checked).

Of course Thom is correct, but what can be done: it is the user computer and the replacement (a user locale) normally follows the language settings.

Something to try for fun!
Add two spaces characters inside Xojo Code Editor and cry… they will be replaced with dot-space… Still the same settings rules.

Good point - edited to clarify.

There are some Declare statements that can be found on the forum you can use to disable the smart quotes.