Function: textsec-single-script-p

textsec-single-script-p is a byte-compiled function defined in textsec.el.gz.

Signature

(textsec-single-script-p STRING)

Documentation

Return non-nil if STRING is all in a single Unicode script.

Note that the concept of "single script" used by this function isn't obvious -- some mixtures of scripts count as a "single script". See

  https://www.unicode.org/reports/tr39/#Mixed_Script_Detection

for details. The Unicode scripts are as defined by the Unicode Standard Annex 24 (UAX#24).

Source Code

;; Defined in /usr/src/emacs/lisp/international/textsec.el.gz
(defun textsec-single-script-p (string)
  "Return non-nil if STRING is all in a single Unicode script.

Note that the concept of \"single script\" used by this function
isn't obvious -- some mixtures of scripts count as a \"single
script\".  See

  https://www.unicode.org/reports/tr39/#Mixed_Script_Detection

for details.  The Unicode scripts are as defined by the
Unicode Standard Annex 24 (UAX#24)."
  (let ((scripts (mapcar
                  (lambda (s)
                    (append s
                            ;; Some scripts used in East Asia are
                            ;; commonly used across borders, so we add
                            ;; those.
                            (mapcan (lambda (script)
                                      (copy-sequence
                                       (textsec--augment-script script)))
                                    s)))
                         (textsec-scripts string))))
    (catch 'empty
      (cl-loop for s1 in scripts
               do (cl-loop for s2 in scripts
                           ;; Common/inherited chars can be used in
                           ;; text with all scripts.
                           when (and (not (memq 'common s1))
                                     (not (memq 'common s2))
                                     (not (memq 'inherited s1))
                                     (not (memq 'inherited s2))
                                     (not (seq-intersection s1 s2)))
                           do (throw 'empty nil)))
      t)))