Handle invalid Unicode strings for %S format like MS does

svn path=/trunk/; revision=8802
This commit is contained in:
Gé van Geldorp 2004-03-19 23:00:35 +00:00
parent 896376d3c1
commit 77eb2df0b2

View file

@ -679,9 +679,20 @@ static int stringw(FILE *f, const wchar_t* sw, int len, int field_width, int pre
}
for (i = 0; i < len; ++i)
{
if (putc((unsigned char)(*sw++), f) == EOF)
return -1;
done++;
#define MB_CUR_MAX 1
char mb[MB_CUR_MAX];
int mbcount, j;
mbcount = wctomb(mb, *sw++);
if (mbcount <= 0)
{
break;
}
for (j = 0; j < mbcount; j++)
{
if (putc(mb[j], f) == EOF)
return -1;
done++;
}
}
while (len < field_width--)
{