+ if (
+#if 1
+ 1
+#else
+ ! NILP (buffer_defaults.enable_multibyte_characters)
+#endif
+ )
+ {
+ /* If TYPE is `TEXT' or `COMPOUND_TEXT', we should decode
+ DATA to Emacs internal format because DATA may be encoded
+ in compound text format. In addtion, if TYPE is `STRING'
+ and DATA contains any 8-bit Latin-1 code, we should also
+ decode it. */
+ if (type == dpyinfo->Xatom_TEXT
+ || type == dpyinfo->Xatom_COMPOUND_TEXT)
+ require_encoding = 1;
+ else if (type == XA_STRING)
+ {
+ int i;
+ for (i = 0; i < size; i++)
+ {
+ if (data[i] >= 0x80)
+ {
+ require_encoding = 1;
+ break;
+ }
+ }
+ }
+ }
+ if (!require_encoding)
+ {
+ str = make_unibyte_string ((char *) data, size);
+ Vlast_coding_system_used = Qraw_text;
+ }
+ else
+ {
+ int bufsize;
+ unsigned char *buf;
+ struct coding_system coding;
+
+ if (NILP (Vnext_selection_coding_system))
+ Vnext_selection_coding_system = Vselection_coding_system;
+ setup_coding_system
+ (Fcheck_coding_system(Vnext_selection_coding_system), &coding);
+ coding.src_multibyte = 0;
+ coding.dst_multibyte = 1;
+ Vnext_selection_coding_system = Qnil;
+ coding.mode |= CODING_MODE_LAST_BLOCK;
+ bufsize = decoding_buffer_size (&coding, size);
+ buf = (unsigned char *) xmalloc (bufsize);
+ decode_coding (&coding, data, buf, size, bufsize);
+ str = make_string_from_bytes ((char *) buf,
+ coding.produced_char, coding.produced);
+ xfree (buf);
+ Vlast_coding_system_used = coding.symbol;
+ }
+ compose_chars_in_text (0, XSTRING (str)->size, str);
+ return str;
+ }