Function: find-multibyte-characters
find-multibyte-characters is a byte-compiled function defined in
mule-cmds.el.gz.
Signature
(find-multibyte-characters FROM TO &optional MAXCOUNT EXCLUDES)
Documentation
Find multibyte characters in the region specified by FROM and TO.
If FROM is a string, find multibyte characters in the string.
The return value is an alist of the following format:
((CHARSET COUNT CHAR ...) ...)
where
CHARSET is a character set,
COUNT is a number of characters,
CHARs are the characters found from the character set.
Optional 3rd arg MAXCOUNT limits how many CHARs are put in the above list.
Optional 4th arg EXCLUDES is a list of character sets to be ignored.
Source Code
;; Defined in /usr/src/emacs/lisp/international/mule-cmds.el.gz
(defun find-multibyte-characters (from to &optional maxcount excludes)
"Find multibyte characters in the region specified by FROM and TO.
If FROM is a string, find multibyte characters in the string.
The return value is an alist of the following format:
((CHARSET COUNT CHAR ...) ...)
where
CHARSET is a character set,
COUNT is a number of characters,
CHARs are the characters found from the character set.
Optional 3rd arg MAXCOUNT limits how many CHARs are put in the above list.
Optional 4th arg EXCLUDES is a list of character sets to be ignored."
(let ((chars nil)
charset char)
(if (stringp from)
(if (multibyte-string-p from)
(let ((idx 0))
(while (setq idx (string-match-p "[^\000-\177]" from idx))
(setq char (aref from idx)
charset (char-charset char))
(unless (memq charset excludes)
(let ((slot (assq charset chars)))
(if slot
(if (not (memq char (nthcdr 2 slot)))
(let ((count (nth 1 slot)))
(setcar (cdr slot) (1+ count))
(if (or (not maxcount) (< count maxcount))
(nconc slot (list char)))))
(setq chars (cons (list charset 1 char) chars)))))
(setq idx (1+ idx)))))
(if enable-multibyte-characters
(save-excursion
(goto-char from)
(while (re-search-forward "[^\000-\177]" to t)
(setq char (preceding-char)
charset (char-charset char))
(unless (memq charset excludes)
(let ((slot (assq charset chars)))
(if slot
(if (not (member char (nthcdr 2 slot)))
(let ((count (nth 1 slot)))
(setcar (cdr slot) (1+ count))
(if (or (not maxcount) (< count maxcount))
(nconc slot (list char)))))
(setq chars (cons (list charset 1 char) chars)))))))))
(nreverse chars)))