I need to allocate a sufficient buffer for format function vswprintf(). When doing the same thing with ANSI string, I'm using:
vsnprintf( NULL, NULL, pszFormat, args );
which returns me required size of a buffer. But it seems that unicode version of this function doesn't have this functionality. When I execute:
vswprintf( NULL, NULL, pszFormat, args );
result value is always -1.
Only solution which I found is using a large static buffer for calculation required size. But I don't like this solution:
static const int nBuffSize = 1024;
static XCHAR evalBuff[nBuffSize];
int nSize = vswprintf( evalBuff, nBuffSize, pszFormat, args );
if ( nSize != -1 )
{
return nSize;
}
else
{
throw XXX;
}
Is there any way how to measure required buffer size for unicode strings?
Regards Ludek