Index: Source/x11/XIMInputServer.m
===================================================================
--- Source/x11/XIMInputServer.m	(revision 34987)
+++ Source/x11/XIMInputServer.m	(working copy)
@@ -68,33 +68,9 @@
 		display: (Display *)dpy
 		   name: (NSString *)name
 {
-  char *locale;
   delegate = aDelegate;
   ASSIGN(server_name, name);
-  dbuf = RETAIN([NSMutableData dataWithCapacity: BUF_LEN]);
 
-  /* Use X11 version of setlocale since many people just set the locale
-     for X. Also just get CTYPE locale (which is typically the one that
-     deals with character handling */
-  locale = setlocale(LC_CTYPE, "");
-  if (XSupportsLocale() != True) 
-    {
-      NSLog(@"Xlib does not support locale setting %s", locale);
-      /* FIXME: Should we reset the locale or just hope that X 
-	 can deal with it? */
-    }
-  encoding = GSEncodingFromLocale(locale);
-#ifndef HAVE_UTF8
-  if (encoding == NSUTF8StringEncoding)
-    encoding = GSUndefinedEncoding;
-#endif
-  if (encoding == GSUndefinedEncoding)
-    {
-      encoding = [NSString defaultCStringEncoding];
-    }
-  NSDebugLLog(@"XIM", @"XIM locale encoding for %s is %@", locale,
-	      [NSString localizedNameOfStringEncoding: encoding]);
-
 #ifdef USE_XIM
   if ([self ximInit: dpy] == NO)
     {
@@ -107,7 +83,6 @@
 - (void) dealloc
 {
   DESTROY(server_name);
-  DESTROY(dbuf);
   [self ximClose];
   [super dealloc];
 }
@@ -129,57 +104,51 @@
 			     window: (gswindow_device_t *)windev
 			     keysym: (KeySym *)keysymptr
 {
-  int count;
-  Status status;
-  NSString *keys;
-  KeySym   keysym;
-  XComposeStatus compose;
-  char *buf = [dbuf mutableBytes];
+  int count = 0;
+  NSString *keys = nil;
+  KeySym keysym = 0;
+  char buf[BUF_LEN];
 
   /* Process characters */
-  keys = nil;
+
+#if 1 
+//defined(HAVE_UTF8) && defined(HAVE_XUTF8LOOKUPSTRING)
   if (windev->ic && event->type == KeyPress)
     {
-      [dbuf setLength: BUF_LEN];
-#ifdef HAVE_UTF8
-#ifdef HAVE_XUTF8LOOKUPSTRING
-      if (encoding == NSUTF8StringEncoding)
-        count = Xutf8LookupString(windev->ic, event, buf, BUF_LEN, 
-      		                  &keysym, &status);
-      else 
-#endif
-#endif
-        count = XmbLookupString(windev->ic, event, buf, BUF_LEN, 
-			        &keysym, &status);
+      Status status = 0;
+      count = Xutf8LookupString(windev->ic, event, buf, BUF_LEN, 
+				&keysym, &status);
 
       if (status==XBufferOverflow)
 	NSDebugLLog(@"NSKeyEvent",@"XmbLookupString buffer overflow\n");
       if (count)
 	{
-	  [dbuf setLength: count];
-	  keys = AUTORELEASE([[NSString alloc] initWithData: dbuf encoding: encoding]);
+	  keys = [[[NSString alloc] initWithBytes: buf
+					   length: count
+					 encoding: NSUTF8StringEncoding] autorelease];
 	}
+      if (status == XLookupKeySym 
+	  || status == XLookupBoth)
+	{
+	  if (keysymptr)
+	    *keysymptr = keysym;
+	}
     }
   else 
+#endif
     {
-      count = XLookupString (event, buf, BUF_LEN, &keysym, &compose);
-      /* Make sure that the string is properly terminated */
-      if (count > BUF_LEN)
-	buf[BUF_LEN] = '\0';
-      else
+      count = XLookupString (event, buf, BUF_LEN, &keysym, NULL);
+      if (count)
 	{
-	  if (count < 1) 
-	    buf[0] = '\0';
-	  else           
-	    buf[count] = '\0';
+	  keys = [[[NSString alloc] initWithBytes: buf
+					   length: count
+					 encoding: NSISOLatin1StringEncoding] autorelease];
 	}
-      if (count)
-	keys = [NSString stringWithCString: buf];
+
+      if (keysymptr)
+	*keysymptr = keysym;
     }
 
-  if (keysymptr)
-    *keysymptr = keysym;
-
   return keys;
 }
 
Index: Headers/x11/XGInputServer.h
===================================================================
--- Headers/x11/XGInputServer.h	(revision 34987)
+++ Headers/x11/XGInputServer.h	(working copy)
@@ -44,8 +44,6 @@
   NSString *server_name;
   XIM       xim;
   XIMStyle  xim_style;
-  NSMutableData   *dbuf;
-  NSStringEncoding encoding;
 
   /* Track the XIC:s and destroy them explicitly to work around an XFree86
   bug:
