Saturday, April 4, 2020

the dumbness of smartquotes

A while back I wrote on upgrading my blog's search function so that it could search phrases in quotes - having studiously recorded quotes and thoughts for two decades, the search is a tremendous resource for me, it's a real delight in being able to reliably retrieve and correctly cite half-remembered passages and repost old links (when they're still viable, sigh.)

I tried to use my blog's search via Safari on my iPad this morning to search for the author "Karen Armstrong"... but got no results, which seemed unlikely. I then realized that searching for both terms separately came up with results that should have returned in the first search... and that the first search was working fine if I ran it from Google Chrome my laptop.

Turns out iPadOS was "helpfully" converting my typed quotes into smartquotes, and that was choking the search. This function from the Inteist website cleared it right up:

function remove_curly_quotes($text) {
    // First, replace UTF-8 characters.
    $text = str_replace(array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"), array("'", "'", '"', '"', '-', '--',
        '...'), $text);
    // Next, replace their Windows-1252 equivalents.
    $text = str_replace(array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)), array("'", "'", '"', '"', '-', '--', '...'), $text);

    return $text;
}

I have guilt about my disdain for smartquotes - much of my professional life is balancing my engineer side - the part of me that's a little insensitive to nuance (rendering me if not faceblind at least a bit face-myopic) but very sharp on recognizing the crux of things and how systems interact - with my wanna-be designer side, that has some knack for wanting to make things look good.

If I was more of a designer, I would be horrified by how many sites and applications are content to use "inch marks" instead of proper, curled-in quotes. But the engineer in me really doesn't like the "Guess What I Mean" interface of a program doing the translation from they key I typed into what the computer believes is "proper"... and inch marks seem to get the job done pretty well in terms of delineating quotes.

(I actually admire some quotation marks used in other countries, especially « » which I just found out are called Guillemets.)

Of course, fighting against autocorrect is probably not a worthy battle. Autocorrect was a secret sauce in the original iPhone, letting our clumsy fat fingers pluck out words from these tiny virtual keys. And while I used to strongly prefer the typographical puns of :-) over the less clever 😀 - especially since different emoji sets can convey different nuanced moods - now I admit that the standard emoji banks have a lot more expressiveness and do a lot to emotionally warm chilled text to in-person conversation standards.

No comments:

Post a Comment