Apocryphal Apostrophes
Published on Jan聽8, 2017 (updated Jul聽1, 2023), filed under design, development. (Share this post, e.g. on Mastodon or on聽Bluesky.)
This is one of 180 articles that you can also read in an ebook: On Web Development聽II.
For JavaScript, W3Schools (caution) says:
The backslash escape character turns special characters into string characters:
var x = 'It\'s alright';
Same for my darling Enki, noting:
str1 = 'I\'m a string.; str2 = "I'm a string.";
str1andstr2output the same string butstr2is easier to read since it doesn鈥檛 require an escape character inI'm.
For Python, Learn Python the Hard Way says:
[鈥you escape double-quotes and single-quotes so Python knows to include in the string. Here鈥檚 an example:"I am 6'2\" tall." # escape double-quote inside string 'I am 6\'2" tall.' # escape single-quote inside string
For Oracle PL/SQL, Tech on the Net says:
When the apostrophe/single quote is in the middle of the string, you need to enter [two] single quotes for Oracle to display a quote symbol. For example:
SELECT 'He''s always the first to arrive'
(This could go on.)
The examples aren鈥檛 perfect, the sources, neither, but what鈥檚 wrong in this picture?
What鈥檚 wrong is what typographers preach for ages: Use real apostrophes.
(On macOS with US keyboard layout, you should be able to type an apostrophe through option + shift + ]. On Windows, use something like alt + 0146.)
Yes, we鈥檒l still need to escape characters鈥攑erhaps the examples simply aren鈥檛 great鈥攁nd tutorials to say how to. But our designs benefit from proper punctuation, and so does our code.
See the punctuation cheat sheet for more characters to use correctly, in more locales.
About Me
I鈥檓 Jens (long: Jens Oliver Meiert), and I鈥檓 an engineering lead, guerrilla philosopher, and indie publisher. I鈥檝e worked as a technical lead and engineering manager for companies you use every day (like Google) and companies you鈥檝e never heard of, I鈥檓 an occasional contributor to web standards (like HTML, CSS, WCAG), and I write and review books for O鈥橰eilly and Frontend Dogma.
I love trying things, not only in web development and engineering management, but also with respect to politics and philosophy. Here on meiert.com I talk about some of my experiences and perspectives. (Please share feedback: Interpret charitably, but do be critical.)
