I must work on windows and with multi language.
I use windows IME to input multi language.
so emacs must accept unicode MS-IME.

I modified emacs23 to accept unicode MS-IME string.
I only known a little C and don't know emacs construction.
so this patch may have many bugs.
I post it here.hope somebody add unicode ime support in emacs23

===========================================

? cscope.out
Index: w32fns.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32fns.c,v
retrieving revision 1.219.2.39
diff -u -r1.219.2.39 w32fns.c
--- w32fns.c    26 Feb 2007 23:03:29 -0000    1.219.2.39
+++ w32fns.c    13 Mar 2007 14:12:21 -0000
@@ -55,6 +55,8 @@
 #include <winspool.h>
 
 #include <dlgs.h>
+#include <imm.h>
+
 #define FILE_NAME_TEXT_FIELD edt1
 
 void syms_of_w32fns ();
@@ -2735,6 +2737,64 @@
     }
 }
 
+static void ime_input (hwnd, msg, wParam, lParam)
+    HWND hwnd;
+    UINT msg;
+    WPARAM wParam;
+    LPARAM lParam;
+{
+    HIMC hIMC;
+    DWORD dwSize;
+    HGLOBAL hstr;
+    LPWSTR lpstr;
+    W32Msg wmsg;
+    DWORD i=0;
+
+    wmsg.dwModifiers = w32_get_key_modifiers (wParam, lParam);
+    hIMC = ImmGetContext(hwnd);
+
+    if (!hIMC)
+        return;
+    //MyError(ERROR_NULLCONTEXT);
+
+    // Get the size of the result string.
+    dwSize = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
+
+    // increase buffer size for terminating null character,
+    //   maybe it is in UNICODE
+    dwSize += sizeof(WCHAR);
+
+    hstr = GlobalAlloc(GHND,dwSize);
+    if (hstr == NULL)
+    {
+        ImmReleaseContext(hwnd, hIMC);
+        return;
+    }
+
+    lpstr = GlobalLock(hstr);
+    if (lpstr == NULL)
+    {
+        ImmReleaseContext(hwnd, hIMC);
+        GlobalFree(hstr);
+    }
+    //MyError(ERROR_GLOBALLOCK);
+
+    // Get the result strings that is generated by IME into lpstr.
+    ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpstr, dwSize);
+    //MessageBoxW(NULL, lpstr , L"inputed", 0);
+    for(i=0; i< dwSize ; i++){
+        if((WCHAR) lpstr[i] == 0x0000){
+            break;
+        }
+        my_post_msg (&wmsg, hwnd, WM_IME_CHAR, lpstr[i], lParam);
+    }
+
+    ImmReleaseContext(hwnd, hIMC);
+
+    // add this string into text buffer of application
+    GlobalUnlock(hstr);
+    GlobalFree(hstr);
+}
 
 static void
 post_character_message (hwnd, msg, wParam, lParam, modifiers)
@@ -3171,6 +3231,15 @@
 
       /* Simulate middle mouse button events when left and right buttons
      are used together, but only if user has two button mouse. */
+
+    /*Modified By ChunlinYao 2007-03-12*/
+    case WM_IME_COMPOSITION:
+      if (lParam & GCS_RESULTSTR)
+      {
+          ime_input(hwnd, msg, wParam, lParam);
+          return 0;
+      }
+      goto dflt;
     case WM_LBUTTONDOWN:
     case WM_RBUTTONDOWN:
       if (w32_num_mouse_buttons > 2)
Index: w32term.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32term.c,v
retrieving revision 1.193.4.40
diff -u -r1.193.4.40 w32term.c
--- w32term.c    26 Feb 2007 23:03:29 -0000    1.193.4.40
+++ w32term.c    13 Mar 2007 12:55:24 -0000
@@ -4447,6 +4447,29 @@
         }
       break;
 
+    case WM_IME_CHAR:
+      f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+
+      if (f && !f->iconified)
+        {
+          if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
+          && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window))
+        {
+          clear_mouse_face (dpyinfo);
+          dpyinfo->mouse_face_hidden = 1;
+        }
+
+          if (temp_index == sizeof temp_buffer / sizeof (short))
+        temp_index = 0;
+          temp_buffer[temp_index++] = msg.msg.wParam ;
+          inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+          inev.code = msg.msg.wParam;
+          inev.modifiers = msg.dwModifiers;
+          XSETFRAME (inev.frame_or_window, f);
+          inev.timestamp = msg.msg.time;
+        }
+      break;
+
     case WM_MOUSEMOVE:
       /* Ignore non-movement.  */
       {


--
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
/_/      中国   ・  江蘇省  ・  南通
/_/
/_/        姚春林
/_/
/_/    E-mail: chunlinyao@gmail.com
/_/    MSN  : chunlinyao@gmail.com
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_