[PATCH 2/4] riched20: Use codepage in ME_ToUnicode. (try 3)

Jactry Zeng jactry92 at gmail.com
Thu Sep 5 21:42:04 CDT 2013


-------------- next part --------------
From 232e792c7259c7b2708d92b80f8fd4a1690b5232 Mon Sep 17 00:00:00 2001
From: Jactry Zeng <jactry92 at gmail.com>
Date: Fri, 6 Sep 2013 09:52:25 +0800
Subject: [PATCH 2/4] riched20: Use codepage in ME_ToUnicode.
To: wine-patches <wine-patches at winehq.org>
Reply-To: wine-devel <wine-devel at winehq.org>

---
 dlls/riched20/editor.c |   15 ++++++++-------
 dlls/riched20/editor.h |    4 ++--
 dlls/riched20/string.c |   12 ++++++------
 3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index e4d0434..4630f28 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3314,10 +3314,9 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
         len = lParam ? strlen((char *)lParam) : 0;
       }
     } else {
-      /* FIXME: make use of pStruct->codepage in the to unicode translation */
-      wszText = lParam ? ME_ToUnicode(bUnicode, (void *)lParam, &len) : NULL;
+      wszText = lParam ? ME_ToUnicode(pStruct->codepage, (void *)lParam, &len) : NULL;
       ME_InsertTextFromCursor(editor, 0, wszText, len, style);
-      ME_EndToUnicode(bUnicode, wszText);
+      ME_EndToUnicode(pStruct->codepage, wszText);
     }
 
     if (bSelection) {
@@ -3505,7 +3504,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
     int from, to, nStartCursor;
     ME_Style *style;
     int len = 0;
-    LPWSTR wszText = lParam ? ME_ToUnicode(unicode, (void *)lParam, &len) : NULL;
+    LONG codepage = unicode ? 1200 : CP_ACP;
+    LPWSTR wszText = lParam ? ME_ToUnicode(codepage, (void *)lParam, &len) : NULL;
     TRACE("EM_REPLACESEL - %s\n", debugstr_w(wszText));
 
     nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
@@ -3520,7 +3520,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
      */
     if (len>0 && wszText[len-1] == '\n')
       ME_ClearTempStyle(editor);
-    ME_EndToUnicode(unicode, wszText);
+    ME_EndToUnicode(codepage, wszText);
     ME_CommitUndo(editor);
     ME_UpdateSelectionLinkAttribute(editor);
     if (!wParam)
@@ -3576,7 +3576,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
       else
       {
         int textLen;
-        LPWSTR wszText = ME_ToUnicode(unicode, (void *)lParam, &textLen);
+        LONG codepage = unicode ? 1200 : CP_ACP;
+        LPWSTR wszText = ME_ToUnicode(codepage, (void *)lParam, &textLen);
         TRACE("WM_SETTEXT - %s\n", debugstr_w(wszText)); /* debugstr_w() */
         if (textLen > 0)
         {
@@ -3593,7 +3594,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
           }
           ME_InsertTextFromCursor(editor, 0, wszText, len, editor->pBuffer->pDefaultStyle);
         }
-        ME_EndToUnicode(unicode, wszText);
+        ME_EndToUnicode(codepage, wszText);
       }
     }
     else
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 5893051..c7413c9 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -109,8 +109,8 @@ void ME_StrDeleteV(ME_String *s, int nVChar, int nChars) DECLSPEC_HIDDEN;
 BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len) DECLSPEC_HIDDEN;
 
 /* smart helpers for A<->W conversions, they reserve/free memory and call MultiByte<->WideChar functions */
-LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz, INT *len) DECLSPEC_HIDDEN;
-void ME_EndToUnicode(BOOL unicode, LPVOID psz) DECLSPEC_HIDDEN;
+LPWSTR ME_ToUnicode(LONG codepage, LPVOID psz, INT *len) DECLSPEC_HIDDEN;
+void ME_EndToUnicode(LONG codepage, LPVOID psz) DECLSPEC_HIDDEN;
 
 static inline int ME_IsWSpace(WCHAR ch)
 {
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c
index 59851b9..db8e508 100644
--- a/dlls/riched20/string.c
+++ b/dlls/riched20/string.c
@@ -172,18 +172,18 @@ ME_CallWordBreakProc(ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT
   }
 }
 
-LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz, INT *len)
+LPWSTR ME_ToUnicode(LONG codepage, LPVOID psz, INT *len)
 {
   assert(psz != NULL);
 
-  if (unicode)
+  if (codepage == 1200)
   {
     if(len) *len = lstrlenW(psz);
     return psz;
   }
   else {
     WCHAR *tmp = NULL;
-    int nChars = MultiByteToWideChar(CP_ACP, 0, psz, -1, NULL, 0);
+    int nChars = MultiByteToWideChar(codepage, 0, psz, -1, NULL, 0);
 
     /* if MultiByteToWideChar failing */
     if(!nChars)
@@ -193,14 +193,14 @@ LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz, INT *len)
     }
 
     if((tmp = ALLOC_N_OBJ(WCHAR, nChars)) != NULL)
-      MultiByteToWideChar(CP_ACP, 0, psz, -1, tmp, nChars);
+      MultiByteToWideChar(codepage, 0, psz, -1, tmp, nChars);
     if(len) *len = nChars - 1;
     return tmp;
   }
 }
 
-void ME_EndToUnicode(BOOL unicode, LPVOID psz)
+void ME_EndToUnicode(LONG codepage, LPVOID psz)
 {
-  if (!unicode)
+  if (codepage == 1200)
     FREE_OBJ(psz);
 }
-- 
1.7.10.4


More information about the wine-patches mailing list