diff options
| author | Eli Zaretskii | 2019-06-22 11:34:23 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-06-22 11:34:23 +0300 |
| commit | 58a3c54c7ea86ea6b715483e7b017008a78fbf14 (patch) | |
| tree | 003d8e6d5ff0d57aa5bb3959887e15dcbf6ea22e | |
| parent | 27d28d43d12999cf04d823ec9e08228d1b862a49 (diff) | |
| download | emacs-58a3c54c7ea86ea6b715483e7b017008a78fbf14.tar.gz emacs-58a3c54c7ea86ea6b715483e7b017008a78fbf14.zip | |
Avoid using string-make-unibyte in select.el
* lisp/select.el (selection-coding-system): Doc fix.
(xselect--encode-string): For C_STRING, if the text is not
already unibyte, use encode-coding-string instead of
string-make-multibyte to make it unibyte.
| -rw-r--r-- | lisp/select.el | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/select.el b/lisp/select.el index af6bf467e4a..935ad10cbf3 100644 --- a/lisp/select.el +++ b/lisp/select.el | |||
| @@ -49,16 +49,17 @@ the current system default encoding on 9x/Me, `utf-16le-dos' | |||
| 49 | 49 | ||
| 50 | For X Windows: | 50 | For X Windows: |
| 51 | When sending text via selection and clipboard, if the target | 51 | When sending text via selection and clipboard, if the target |
| 52 | data-type matches with the type of this coding system, it is used | 52 | data-type matches this coding system according to the table |
| 53 | for encoding the text. Otherwise (including the case that this | 53 | below, it is used for encoding the text. Otherwise (including |
| 54 | variable is nil), a proper coding system is used as below: | 54 | the case that this variable is nil), a proper coding system is |
| 55 | selected as below: | ||
| 55 | 56 | ||
| 56 | data-type coding system | 57 | data-type coding system |
| 57 | --------- ------------- | 58 | --------- ------------- |
| 58 | UTF8_STRING utf-8 | 59 | UTF8_STRING utf-8 |
| 59 | COMPOUND_TEXT compound-text-with-extensions | 60 | COMPOUND_TEXT compound-text-with-extensions |
| 60 | STRING iso-latin-1 | 61 | STRING iso-latin-1 |
| 61 | C_STRING no-conversion | 62 | C_STRING raw-text-unix |
| 62 | 63 | ||
| 63 | When receiving text, if this coding system is non-nil, it is used | 64 | When receiving text, if this coding system is non-nil, it is used |
| 64 | for decoding regardless of the data-type. If this is nil, a | 65 | for decoding regardless of the data-type. If this is nil, a |
| @@ -476,10 +477,15 @@ two markers or an overlay. Otherwise, it is nil." | |||
| 476 | (setq str (encode-coding-string str coding))) | 477 | (setq str (encode-coding-string str coding))) |
| 477 | 478 | ||
| 478 | ((eq type 'C_STRING) | 479 | ((eq type 'C_STRING) |
| 479 | ;; If STR is unibyte (the normal case), use it; otherwise | 480 | ;; According to ICCCM Protocol v2.0 (para 2.7.1), C_STRING |
| 480 | ;; we assume some of the characters are eight-bit, and | 481 | ;; is a zero-terminated sequence of raw bytes that |
| 481 | ;; take their lower 8 bits. | 482 | ;; shouldn't be interpreted as text in any encoding. |
| 482 | (setq str (string-make-unibyte str))) | 483 | ;; Therefore, if STR is unibyte (the normal case), we use |
| 484 | ;; it as-is; otherwise we assume some of the characters | ||
| 485 | ;; are eight-bit and ensure they are converted to their | ||
| 486 | ;; single-byte representation. | ||
| 487 | (or (null (multibyte-string-p str)) | ||
| 488 | (setq str (encode-coding-string 'raw-text-unix str)))) | ||
| 483 | 489 | ||
| 484 | (t | 490 | (t |
| 485 | (error "Unknown selection type: %S" type))))) | 491 | (error "Unknown selection type: %S" type))))) |