diff options
author | jstebbins <[email protected]> | 2013-09-22 17:19:38 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2013-09-22 17:19:38 +0000 |
commit | 5e712218d8eb3f71a06356ed6f952b86ca947fca (patch) | |
tree | cd20ec0c7f22a94c11594deb195c7ec939dee4d1 /libhb/common.c | |
parent | 10fda25f44d362349694a42127e8ba4974a4a6ad (diff) |
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
Diffstat (limited to 'libhb/common.c')
-rw-r--r-- | libhb/common.c | 19 |
1 files changed, 19 insertions, 0 deletions
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 <windows.h> +#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 ); } |