aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/international/mule-util.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el
index 3fd3a57b68b..c6316358dac 100644
--- a/lisp/international/mule-util.el
+++ b/lisp/international/mule-util.el
@@ -287,6 +287,38 @@ or one is an alias of the other."
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.
293All coding systems in the list can safely encode any multibyte characters
294in the region.
295
296If the region contains no multibyte charcters, the returned list
297contains a single element `undecided'.
298
299Kludgy feature: if FROM is a string, then that string is the target
300for 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