From 5545da583ed4734192f3bcd2b41b20fcbc9e82e5 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 13 Dec 2012 17:42:25 +0800 Subject: [2/2] libs/wine: Output unicode strings in UTF-8 encoding. (eterbug #8867) Content-Type: text/plain; charset=UTF-8 --- libs/wine/debug.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/wine/debug.c b/libs/wine/debug.c index 36ca5ba511..722ce83bfd 100644 --- a/libs/wine/debug.c +++ b/libs/wine/debug.c @@ -40,6 +40,7 @@ WINE_DECLARE_DEBUG_CHANNEL(pid); #endif static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" }; +static const union cptable *ansi_cptable; #define MAX_DEBUG_OPTIONS 256 @@ -233,8 +234,16 @@ static void debug_init(void) } if ((wine_debug = getenv("WINEDEBUG"))) { + char *lang; + if (!strcmp( wine_debug, "help" )) debug_usage(); parse_options( wine_debug ); + + lang = getenv("LANG"); + if (!strncasecmp(lang, "ru_RU", 5)) + ansi_cptable = wine_cp_get_table( 1251 ); + else + ansi_cptable = wine_cp_get_table( 1252 ); } } @@ -309,7 +318,6 @@ static void release_temp_buffer( char *buffer, size_t size ) /* default implementation of wine_dbgstr_an */ static const char *default_dbgstr_an( const char *str, int n ) { - static const char hex[16] = "0123456789abcdef"; char *dst, *res; size_t size; @@ -340,10 +348,10 @@ static const char *default_dbgstr_an( const char *str, int n ) *dst++ = c; else { - *dst++ = '\\'; - *dst++ = 'x'; - *dst++ = hex[(c >> 4) & 0x0f]; - *dst++ = hex[c & 0x0f]; + WCHAR wc; + /* eterhack: output strings in UTF-8 encoding */ + wine_cp_mbstowcs(ansi_cptable, 0, (char *)&c, 1, &wc, 1); + dst += wine_utf8_wcstombs(0, &wc, 1, dst, 4); } } } -- 2.13.3