mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
Handle invalid Unicode strings for %S format like MS does
svn path=/trunk/; revision=8802
This commit is contained in:
parent
896376d3c1
commit
77eb2df0b2
1 changed files with 14 additions and 3 deletions
|
@ -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--)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue