[Wine-patches] [eterhack] libs/wine: Output unicode strings in UTF-8 encoding. (eterbug #8867)

Dmitry Timoshkov dtimoshkov на etersoft.ru
Чт Дек 13 13:42:25 MSK 2012


---
 libs/wine/debug.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libs/wine/debug.c b/libs/wine/debug.c
index 61f641f..6305310 100644
--- a/libs/wine/debug.c
+++ b/libs/wine/debug.c
@@ -35,6 +35,7 @@
 #include "wine/unicode.h"
 
 static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" };
+static const union cptable *ansi_cptable;
 
 #define MAX_DEBUG_OPTIONS 256
 
@@ -205,8 +206,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 );
     }
 }
 
@@ -312,10 +321,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);
             }
         }
     }
-- 
1.8.0.1



Подробная информация о списке рассылки Wine-patches