aboutsummaryrefslogtreecommitdiffstats
path: root/src/xselect.c
diff options
context:
space:
mode:
authorKenichi Handa <[email protected]>1997-05-10 03:37:01 +0000
committerKenichi Handa <[email protected]>1997-05-10 03:37:01 +0000
commitf78da51e8dc0b1f8e7756e6b12954d79f1cd3d1c (patch)
treed56626d28841e6528ab7e882fda36e03aa4f28aa /src/xselect.c
parent34910d41c1de3669e94f1a3deb5a1f335d5d002c (diff)
(selection_data_to_lisp_data): If TYPE is `STRING'
and DATA contains 8-bit codes, decode them as Latin-1 characters. (lisp_data_to_selection_data): Supply 4th arg TABLE as Qnil to find_charset_in_str.
Diffstat (limited to 'src/xselect.c')
-rw-r--r--src/xselect.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/xselect.c b/src/xselect.c
index 8a8bf362dc..cf2fe19a4a 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1463,14 +1463,31 @@ selection_data_to_lisp_data (display, data, size, type, format)
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;
@@ -1588,7 +1605,7 @@ lisp_data_to_selection_data (display, obj,
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]))
{