winex11.drv: Convert wide char preedit text.
Kusanagi Kouichi
slash at ma.neweb.ne.jp
Thu Apr 17 16:24:02 CDT 2008
WCHAR may differ from wchar_t. So wide char text shouldn't be used directly.
---
dlls/winex11.drv/xim.c | 50 ++++++++++++++++++++++++++---------------------
1 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c
index e8bf3bb..99ce829 100644
--- a/dlls/winex11.drv/xim.c
+++ b/dlls/winex11.drv/xim.c
@@ -228,7 +228,7 @@ static void XIMPreEditDoneCallback(XIC ic, XPointer client_data, XPointer call_d
dwPreeditPos = 0;
}
-static void XIMPreEditDrawCallback(XIM ic, XPointer client_data,
+static void XIMPreEditDrawCallback(XIC ic, XPointer client_data,
XIMPreeditDrawCallbackStruct *P_DR)
{
TRACE("PreEditDrawCallback %p\n",ic);
@@ -239,35 +239,41 @@ static void XIMPreEditDrawCallback(XIM ic, XPointer client_data,
int len = P_DR->chg_length;
if (P_DR->text)
{
+ char *mbs;
+ DWORD dwOutput;
+ WCHAR *wcOutput;
+
if (! P_DR->text->encoding_is_wchar)
{
- DWORD dwOutput;
- WCHAR *wcOutput;
-
TRACE("multibyte\n");
- dwOutput = MultiByteToWideChar(CP_UNIXCP, 0,
- P_DR->text->string.multi_byte, -1,
- NULL, 0);
- wcOutput = HeapAlloc(GetProcessHeap(), 0, sizeof (WCHAR) * dwOutput);
- if (wcOutput)
- {
- dwOutput = MultiByteToWideChar(CP_UNIXCP, 0,
- P_DR->text->string.multi_byte, -1,
- wcOutput, dwOutput);
-
- /* ignore null */
- dwOutput --;
- X11DRV_ImmSetInternalString (GCS_COMPSTR, sel, len, wcOutput, dwOutput);
- HeapFree(GetProcessHeap(), 0, wcOutput);
- }
+ mbs = P_DR->text->string.multi_byte;
}
else
{
- FIXME("wchar PROBIBILY WRONG\n");
+ int mblen;
+
+ TRACE("wide char\n");
+ mblen = wcstombs(NULL, P_DR->text->string.wide_char, 0);
+ mbs = HeapAlloc(GetProcessHeap(), 0, mblen);
+ if (!mbs)
+ return;
+ }
+
+ dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, mbs, -1, NULL, 0);
+ wcOutput = HeapAlloc(GetProcessHeap(), 0, sizeof (WCHAR) * dwOutput);
+ if (wcOutput)
+ {
+ dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, mbs, -1, wcOutput, dwOutput);
+
+ /* ignore null */
+ dwOutput --;
X11DRV_ImmSetInternalString (GCS_COMPSTR, sel, len,
- (LPWSTR)P_DR->text->string.wide_char,
- P_DR->text->length);
+ wcOutput, dwOutput);
+ HeapFree(GetProcessHeap(), 0, wcOutput);
}
+
+ if (! P_DR->text->encoding_is_wchar)
+ HeapFree(GetProcessHeap(), 0, mbs);
}
else
X11DRV_ImmSetInternalString (GCS_COMPSTR, sel, len, NULL, 0);
--
1.5.5
More information about the wine-patches
mailing list