I have following C++ code sample:
void SetVaArgs(const char* fmt, const va_list argList)
{
setlocale( LC_ALL, "C" );
// 1
m_FormatBufferLen = ::_vsnprintf(m_FormatBuffer, Logger::MAX_LOGMESSAGE_SIZE, fmt, argList);
setlocale( LC_ALL, "" );
//2
m_FormatBufferLen = ::_vsnprintf(m_FormatBuffer, Logger::MAX_LOGMESSAGE_SIZE, fmt, argList);
_locale_t locale = _create_locale(LC_ALL, "C");;
//3
m_FormatBufferLen = ::_vsnprintf_l(m_FormatBuffer, Logger::MAX_LOGMESSAGE_SIZE, fmt,locale, argList);
The arglist contains LPCTSTR with extended ascii characters. Command //1 copies it to the buffer, as expected. Command //2 stops copying at first character from range 129-161 (few exceptions there).
I'd like to address this issue without changing global locale for process, but command //3 works like //2, why? I'm passing "C" locale, so I would expect effect from command //1.
By default I'm using Polish locale on english Windows XP.