Smart-quote behavior: Is current behavior ideal?

  • Thread starter Alex K. Angelopoulos [MVP]
  • Start date

Alex K. Angelopoulos [MVP]

Since early in the beta, PowerShell has treated smart quote characters as
interchangeable with their ASCII counterparts. In other words, all of the
following act like a double quote character:
" (character 0x0022, Double Quotation Mark)
" (character 0x201c, Left Double Quotation Mark)
" (character 0x201d, Right Double Quotation Mark)
And the following are treated as interchangeable single quotes:
' (character 0x0027, Single Quotation Mark)
' (character 0x2018, Left Single Quotation Mark)
' (character 0x2019, Right Single Quotation Mark)

I was one of the people proposing this choice, for the following reasons:
(1) Admins often perform cut-and-paste from web pages or Word documents, all
of which may end up with hard-to-detect smartquoting in code samples due to
autoreplacement features.
(2) The grammar for at least one .NET language, VB.NET, specifically treats
these characters in this way as well.

I'm curious now about other opinions on this feature. I can't see any major
issues with it, although I have noticed that smart double quote characters
are allowed in file names, potentially causing problems in some string
expansion scenarios. There are also some other interesting possible tweaks,
although they clearly can't be done for first release and might be more
trouble than they are worth. Here are the alternative treatments I was
thinking of:

(1) Smart quotes as distinct quotes:
It might be useful to treat smart quotes as distinct from their ASCII
counterparts. For example, a smart double quote, whether open or close,
could delimit a string containing normal double quotes. Smart double quoted
strings would allow substitution just as normal double quoted strings do;
smart single quoted strings would not allow substitution and could contain
ASCII single quotes.

(2) Directional smart quotes:
Like (1), but if you are delimiting a string with smart quotes it must start
with a left quote marker and end with a right quote marker.

The most significant disadvantage I see to either possibility is that it can
be hard to identify smart quotes even in Consolas - the most clear font when
small-sized - and it is virtually impossible with raster fonts.

My Computer