diff options
author | megamage <none@none> | 2009-08-19 17:02:29 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-19 17:02:29 -0500 |
commit | f5085b2f39c91ed0103c79d95f8d18a4ef2a6371 (patch) | |
tree | cba9f8c0706f9db972cb915d27ee9e7fd3daf1d5 /src/shared/Util.cpp | |
parent | d7e4392f796f5624a75216f64ae7520c00439cb9 (diff) |
[8388] Replaced UTF8PRINT macro by a function
Should also fix possible color leak on Windows CLI.
Signed-off-by: freghar <compmancz@gmail.com>
--HG--
branch : trunk
Diffstat (limited to 'src/shared/Util.cpp')
-rw-r--r-- | src/shared/Util.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp index 644769f2069..3d3b205209a 100644 --- a/src/shared/Util.cpp +++ b/src/shared/Util.cpp @@ -478,3 +478,28 @@ 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 +} |