From 5e712218d8eb3f71a06356ed6f952b86ca947fca Mon Sep 17 00:00:00 2001 From: jstebbins Date: Sun, 22 Sep 2013 17:19:38 +0000 Subject: libhb: make libhb internal character code utf8 This makes libhb expect all strings passed to it to be in utf8 format. The cli converts the converts from the current code page to utf8. libhb converts back to the current code page when necessary for libraries that expect it. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5798 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/common.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libhb/common.c') diff --git a/libhb/common.c b/libhb/common.c index 3d5cf36fb..7087046b6 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -19,6 +19,10 @@ #include "qsv_common.h" #endif +#ifdef SYS_MINGW +#include +#endif + /********************************************************************** * Global variables *********************************************************************/ @@ -2560,6 +2564,21 @@ void hb_valog( hb_debug_level_t level, const char * prefix, const char * log, va /* Add the end of line */ strcat( string, "\n" ); +#ifdef SYS_MINGW + wchar_t wstring[2*362]; /* 360 chars + \n + \0 */ + + // Convert internal utf8 to "console output code page". + // + // This is just bizarre windows behavior. You would expect that + // printf would automatically convert a wide character string to + // the current "console output code page" when using the "%ls" format + // specifier. But it doesn't... so we must do it. + if (!MultiByteToWideChar(CP_UTF8, 0, string, -1, wstring, sizeof(wstring))) + return; + if (!WideCharToMultiByte(GetConsoleOutputCP(), 0, wstring, -1, string, sizeof(string), NULL, NULL)) + return; +#endif + /* Print it */ fprintf( stderr, "%s", string ); } -- cgit v1.2.3