I need to allocate a sufficient buffer for the vswprintf () format function. When you do the same with the ANSI string, I use:
vsnprintf( NULL, NULL, pszFormat, args );
which returns me the required buffer size. But it looks like the Unicode version of this function does not have this function. When I execute:
vswprintf( NULL, NULL, pszFormat, args );
The result value is always -1.
The only solution I found was to use a large static buffer to calculate the required size. But I do not 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 a way to measure the size of the required buffer for unicode strings?
Relations Ludek
source
share