176 |
(if coding |
(if coding |
177 |
(setq coding (coding-system-base coding)) |
(setq coding (coding-system-base coding)) |
178 |
(setq coding 'raw-text)) |
(setq coding 'raw-text)) |
179 |
;; Suppress producing escape sequences for compositions. |
(let ((inhibit-read-only t)) |
180 |
(remove-text-properties 0 (length str) '(composition nil) str) |
;; Suppress producing escape sequences for compositions. |
181 |
(cond |
(remove-text-properties 0 (length str) '(composition nil) str) |
182 |
((eq type 'TEXT) |
(cond |
183 |
(if (not (multibyte-string-p str)) |
((eq type 'TEXT) |
184 |
;; Don't have to encode unibyte string. |
(if (not (multibyte-string-p str)) |
185 |
(setq type 'STRING) |
;; Don't have to encode unibyte string. |
186 |
;; If STR contains only ASCII, Latin-1, and raw bytes, |
(setq type 'STRING) |
187 |
;; encode STR by iso-latin-1, and return it as type |
;; If STR contains only ASCII, Latin-1, and raw bytes, |
188 |
;; `STRING'. Otherwise, encode STR by CODING. In that |
;; encode STR by iso-latin-1, and return it as type |
189 |
;; case, the returing type depends on CODING. |
;; `STRING'. Otherwise, encode STR by CODING. In that |
190 |
(let ((charsets (find-charset-string str))) |
;; case, the returing type depends on CODING. |
191 |
(setq charsets |
(let ((charsets (find-charset-string str))) |
192 |
(delq 'ascii |
(setq charsets |
193 |
(delq 'latin-iso8859-1 |
(delq 'ascii |
194 |
(delq 'eight-bit-control |
(delq 'latin-iso8859-1 |
195 |
(delq 'eight-bit-graphic charsets))))) |
(delq 'eight-bit-control |
196 |
(if charsets |
(delq 'eight-bit-graphic charsets))))) |
197 |
(setq str (encode-coding-string str coding) |
(if charsets |
198 |
type (if (memq coding '(compound-text |
(setq str (encode-coding-string str coding) |
199 |
compound-text-with-extensions)) |
type (if (memq coding '(compound-text |
200 |
'COMPOUND_TEXT |
compound-text-with-extensions)) |
201 |
'STRING)) |
'COMPOUND_TEXT |
202 |
(setq type 'STRING |
'STRING)) |
203 |
str (encode-coding-string str 'iso-latin-1)))))) |
(setq type 'STRING |
204 |
|
str (encode-coding-string str 'iso-latin-1)))))) |
205 |
|
|
206 |
((eq type 'COMPOUND_TEXT) |
((eq type 'COMPOUND_TEXT) |
207 |
(setq str (encode-coding-string str coding))) |
(setq str (encode-coding-string str coding))) |
208 |
|
|
209 |
((eq type 'STRING) |
((eq type 'STRING) |
210 |
(if (memq coding '(compound-text |
(if (memq coding '(compound-text |
211 |
compound-text-with-extensions)) |
compound-text-with-extensions)) |
212 |
(setq str (string-make-unibyte str)) |
(setq str (string-make-unibyte str)) |
213 |
(setq str (encode-coding-string str coding)))) |
(setq str (encode-coding-string str coding)))) |
214 |
|
|
215 |
((eq type 'UTF8_STRING) |
((eq type 'UTF8_STRING) |
216 |
(setq str (encode-coding-string str 'utf-8))) |
(setq str (encode-coding-string str 'utf-8))) |
217 |
|
|
218 |
(t |
(t |
219 |
(error "Unknow selection type: %S" type)) |
(error "Unknow selection type: %S" type)) |
220 |
)) |
))) |
221 |
|
|
222 |
(setq next-selection-coding-system nil) |
(setq next-selection-coding-system nil) |
223 |
(cons type str)))) |
(cons type str)))) |