LISTBOX: return the correct character count in DBCS locales

Mike McCormack mike at codeweavers.com
Thu Aug 26 04:18:40 CDT 2004


In some locales, two bytes represent one character, so returning 
strlenW(str) as the number of characters required for str in the ASCII 
code page is incorrect for some cases.

Mike


ChangeLog:
* return the correct character count in DBCS locales
-------------- next part --------------
Index: controls/listbox.c
===================================================================
RCS file: /home/wine/wine/controls/listbox.c,v
retrieving revision 1.105
diff -u -r1.105 listbox.c
--- controls/listbox.c	17 Aug 2004 22:29:29 -0000	1.105
+++ controls/listbox.c	26 Aug 2004 07:50:56 -0000
@@ -778,7 +778,13 @@
     if (HAS_STRINGS(descr))
     {
         if (!lParam)
-            return strlenW(descr->items[index].str);
+        {
+            DWORD len = strlenW(descr->items[index].str);
+            if( unicode )
+                return len;
+            return WideCharToMultiByte( CP_ACP, 0, descr->items[index].str, len,
+                                        NULL, 0, NULL, NULL );
+        }
 
 	TRACE("index %d (0x%04x) %s\n", index, index, debugstr_w(descr->items[index].str));
 


More information about the wine-patches mailing list