[8388] Replaced UTF8PRINT macro by a function

Should also fix possible color leak on Windows CLI.

Signed-off-by: freghar <compmancz@gmail.com>
This commit is contained in:
freghar 2009-08-18 20:00:45 +02:00
parent 65e723ba9e
commit 17b94e1e09
4 changed files with 37 additions and 36 deletions

View file

@ -419,3 +419,29 @@ bool Utf8FitTo(const std::string& str, std::wstring search)
return true;
}
void utf8printf(FILE *out, const char *str, ...)
{
va_list ap;
#if PLATFORM == PLATFORM_WINDOWS
char temp_buf[32*1024];
wchar_t wtemp_buf[32*1024];
size_t temp_len;
size_t wtemp_len;
va_start(ap, str);
temp_len = vsnprintf(temp_buf, 32*1024, str, ap);
va_end(ap);
wtemp_len = 32*1024-1;
Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len);
CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len+1);
fprintf(out, temp_buf);
#else
va_start(ap, str);
vfprintf(out, str, ap);
va_end(ap);
#endif
}