else if (format == 8)
{
Lisp_Object str;
-
- if (type != dpyinfo->Xatom_TEXT && type != dpyinfo->Xatom_COMPOUND_TEXT)
+ int require_encoding = 0;
+
+ /* 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_string ((char *) data, size);
else
{
- /* If TYPE is `TEXT' or `COMPOUND_TEXT', we should decode
- DATA to Emacs internal format because DATA may be
- encoded in compound text format. */
int bufsize, dummy;
unsigned char *buf;
struct coding_system coding;
bzero (charsets, MAX_CHARSET + 1);
num = ((*size_ret <= 1) /* Check the possibility of short cut. */
? 0
- : find_charset_in_str (*data_ret, *size_ret, charsets));
+ : find_charset_in_str (*data_ret, *size_ret, charsets, Qnil));
if (!num || (num == 1 && charsets[CHARSET_ASCII]))
{