- temp_buffer[temp_index++] = copy_buffer[i];
- bufp->kind = ascii_keystroke;
- bufp->code = copy_buffer[i];
+ temp_buffer[temp_index++] = copy_bufptr[i];
+ }
+
+ if (/* If the event is not from XIM, */
+ event.xkey.keycode != 0
+ /* or the current locale doesn't request
+ decoding of the intup data, ... */
+ || coding.type == coding_type_raw_text
+ || coding.type == coding_type_no_conversion)
+ {
+ /* ... we can use the input data as is. */
+ nchars = nbytes;
+ }
+ else
+ {
+ /* We have to decode the input data. */
+ int require;
+ unsigned char *p;
+
+ require = decoding_buffer_size (&coding, nbytes);
+ p = (unsigned char *) alloca (require);
+ coding.mode |= CODING_MODE_LAST_BLOCK;
+ decode_coding (&coding, copy_bufptr, p,
+ nbytes, require);
+ nbytes = coding.produced;
+ nchars = coding.produced_char;
+ copy_bufptr = p;
+ }
+
+ /* Convert the input data to a sequence of
+ character events. */
+ for (i = 0; i < nbytes; i += len)
+ {
+ c = STRING_CHAR_AND_LENGTH (copy_bufptr + i,
+ nbytes - i, len);
+ bufp->kind = (SINGLE_BYTE_CHAR_P (c)
+ ? ascii_keystroke
+ : multibyte_char_keystroke);
+ bufp->code = c;