comparison lisp/international/mule-util.el @ 20162:dc6f12ef4d47

(find-safe-coding-system): New function.
author Kenichi Handa <handa@m17n.org>
date Thu, 23 Oct 1997 12:05:45 +0000
parents 00ca5f419c16
children 42d729244a85
comparison
equal deleted inserted replaced
20161:0d9c6ccdc45c 20162:dc6f12ef4d47
285 (let ((eol-type-1 (coding-system-eol-type coding-system-1)) 285 (let ((eol-type-1 (coding-system-eol-type coding-system-1))
286 (eol-type-2 (coding-system-eol-type coding-system-2))) 286 (eol-type-2 (coding-system-eol-type coding-system-2)))
287 (or (eq eol-type-1 eol-type-2) 287 (or (eq eol-type-1 eol-type-2)
288 (and (vectorp eol-type-1) (vectorp eol-type-2))))))) 288 (and (vectorp eol-type-1) (vectorp eol-type-2)))))))
289 289
290 ;;;###autoload
291 (defun find-safe-coding-system (from to)
292 "Return a list of proper coding systems to encode a text between FROM and TO.
293 All coding systems in the list can safely encode any multibyte characters
294 in the region.
295
296 If the region contains no multibyte charcters, the returned list
297 contains a single element `undecided'.
298
299 Kludgy feature: if FROM is a string, then that string is the target
300 for finding proper coding systems, and TO is ignored."
301 (let ((found (if (stringp from)
302 (find-charset-string from)
303 (find-charset-region from to)))
304 (l coding-system-list)
305 codings coding safe)
306 (if (and (= (length found) 1)
307 (eq 'ascii (car found)))
308 '(undecided)
309 (while l
310 (setq coding (car l) l (cdr l))
311 (if (and (eq coding (coding-system-base coding))
312 (setq safe (coding-system-get coding 'safe-charsets))
313 (or (eq safe t)
314 (catch 'tag
315 (mapcar (function (lambda (x)
316 (if (not (memq x safe))
317 (throw 'tag nil))))
318 found))))
319 (setq codings (cons coding codings))))
320 codings)))
321
290 322
291 ;;; Composite charcater manipulations. 323 ;;; Composite charcater manipulations.
292 324
293 ;;;###autoload 325 ;;;###autoload
294 (defun compose-region (start end) 326 (defun compose-region (start end)