Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From <a href="http://www.globalyzer.com/gzserver/help/localeSensitiveMethods/formatting.htm#larges" rel="nofollow">http://www.globalyzer.com/gzserver/help/localeSensitiveMethods/formatting.htm#larges</a></p> <p>Unqualified String Specifiers (large %S)</p> <p>These tables show how Windows and ANSI treat parameters based on the %S specifier and the style of function call (single, generic, or wide):</p> <pre> Windows function Specifier Parameter needs to be printf/sprintf (single/MBCS) %S wchar_t* _tprintf/_stprintf (generic) %S (don't use) wprintf/swprintf (wide) %S char* ANSI function Specifier Parameter needs to be printf/sprintf (single/MBCS) %S wchar_t* wprintf/swprintf (wide) %S wchar_t* </pre> <p>Both ANSI and Windows treat %S basically as opposite of %s in terms of single byte or wide, which ironically means that Windows and ANSI again handle these specifiers differently.</p> <p>Note that ANSI in essence always treats %S in the same way as %ls, in other words it is always assumed to be wide string.</p> <p>Windows on the other hand treats %S differently based on the type of function call. For single byte function calls, %S acts like the wide %ls specifier, but for wide functions calls, %S acts like the single byte %hs specifier.</p> <p>This specifier should not be used for Windows Generic calls. Since %S is the "opposite" of %s, the parameter would need to be wide if the _UNICODE flag is off, and single byte if the _UNICODE flag is on. The TCHAR generic type does not work this way, and there's not "anti-TCHAR" kind of datatype.</p> <p>I tried the following in Visual C++ 2010:</p> <pre><code>#include "stdafx.h" #include &lt;Windows.h&gt; int _tmain(int argc, _TCHAR* argv[]) { WCHAR cBuf[MAX_PATH]; TCHAR tBuf[MAX_PATH]; wcsncpy_s(cBuf, L"Testing\r\n", MAX_PATH); _tcsncpy_s(tBuf, _T("Testing\r\n"), MAX_PATH); printf("%S", cBuf); // Microsoft extension printf("%ls", cBuf); // works in VC++ 2010 wprintf(L"%s", cBuf); // wide _tprintf(_T("%s"), tBuf); // single-byte/wide return 0; } </code></pre> <p>Settings:</p> <p>/ZI /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"Debug\TestWchar.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /analyze- /errorReport:queue </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload