Ask Reuben
Smart Quotes
What is a Smart Quote?
Why has copying and pasting input caused an error?
Why does my code not compile after I copied and pasted an example?
Smart Quotes were something that I first encountered in the early days of the Genero Desktop Client. Issues were being reported after users pasted text into a TEXTEDIT. The issue can occur with EDIT, BUTTONEDIT as well but is more likely to occur with the TEXTEDIT as users are more likely to paste large blocks of text as opposed to a single word. Upon investigation it was discovered that the text users were copying and pasting into the TEXTEDIT widget contained what are known as “smart quotes”. As an exercise to see a smart quote, in a product such as Word, try and produce the following …
… the first DISPLAY “Hello World” I have typed into Word, the second I have copied and pasted from Genero Studio. Pay attention to the quotes. In the line that I typed we see that the quotes are different …
… In the line copied and pasted from Genero Studio both quotes are the same …
These different quotes are what is called smart quotes and are a feature of Word Processing applications. There is normally a preference or a setting where you can enable/disable them …
Why they cause a problem is that the receiving program or database it had only ever been considered that a user would type a character in the range of printable characters from the ASCII tables, that is from ASCII 32 to ASCII 126. (or maybe more characters depending on your locale settings)
These smart quotes are outside this range, for instance the Left Double Quotation Mark, and the Right Double Quotation Mark have Unicode entries and HTML Entity Codes as listed in those links. If the receiving program wasn’t using an encoding that would cope with this, then an error could result. One approach was to parse what was received and not allow the user out of the field until the smart quote had been removed so that it did not hit the database.
These days the more typical place to encounter the issue is with code editors. Someone will type some code outside a code editor and not realise that smart quotes have been added. Then when they cut and paste into Genero Studio they might see …
… the compiler is expecting to see a single, double, or back quote, not a smart quote. So if you see an error where your code looks right and you and have copy and pasted it from somewhere, look closely at the quotes. Are the quotes the same, or are they different? If they are different, chances are you are looking at a set of smart quotes and you need to edit them to be single, double, or back quote.