The closing double quotes are at position "22 in the OT1 encoding and position "11 in the T1 encoding.
So
\sfcode"22=0
or
\sfcode"11=0
will do, according to the chosen encoding. If you want a magic for setting the space factor code independently of the encoding (OT1 or T1), then
\AtBeginDocument{
\sfcode\csname\encodingdefault\string\textquotedblright\endcsname=0
}
is what you're looking for. Here's the test document:
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} % Or fontspec with XeLaTeX/LuaLaTeX
\AtBeginDocument{
\sfcode\csname\encodingdefault\string\textquotedblright\endcsname=0
}
\begin{document}
Compare:
``Is the spacing correct?\@'' he asked.
``Is the spacing correct?'' he asked.
“Is the spacing correct?\@” he asked.
“Is the spacing correct?” he asked.
\end{document}
With or without the fontenc line the output is the same.
For XeLaTeX/LuaLaTeX, setting \sfcode`”=0 is correct.
Let's examine the case of pdflatex. The definitions found in ts1enc.dfu and t1enc.dfu, which are loaded when the OT1 or T1 encoding are loaded is
\DeclareUnicodeCharacter{201D}{\textquotedblright}
but it's \textquotedblright that changes meaning depending on the encoding. For OT1 it's "typeset the character in position "22", which is equivalent to \"; but for T1 it's the character in position "11. This may be declared by
\sfcode`\^^Q=0
but it's inconvenient having to give different definitions. Fortunately, the cryptic instruction
\sfcode\csname\encodingdefault\string\textquotedblright\endcsname=0
accesses precisely \OT1\textquotedblright or \T1\textquotedblright, which is the symbolic name of the right slot, depending on the default encoding.
\sfcode`"=0will work with the OT1 encoding, it won't for T1 (inpdflatex). – egreg Jun 11 '12 at 07:09OT1encoding,"selects the closing double quotation mark. InT1encoding, however,"selects the straight double quotation mark. – mhp Jun 16 '12 at 14:47