Add new function textsec-mixed-numbers-p

* lisp/international/textsec.el (textsec-mixed-numbers-p): New
function.
This commit is contained in:
Lars Ingebrigtsen 2022-01-17 17:32:58 +01:00
parent 9b358a99d6
commit 1c7307673b
2 changed files with 20 additions and 0 deletions

View file

@ -152,6 +152,21 @@ Levels are (in order of restrictiveness) `ascii-only',
(t
'unrestricted))))
(defun textsec-mixed-numbers-p (string)
"Return non-nil if there are numbers from different decimal systems in STRING."
(> (length
(seq-uniq
(textsec-scripts
(apply #'string
(seq-filter (lambda (char)
;; We're selecting the characters that
;; have a numeric property.
(eq (get-char-code-property char 'general-category)
'Nd))
string)))
#'equal))
1))
(provide 'textsec)
;;; textsec.el ends here

View file

@ -81,4 +81,9 @@
(should (eq (textsec-restriction-level "Сirсlе")
'unrestricted)))
(ert-deftest test-mixed-numbers ()
(should-not (textsec-mixed-numbers-p "foo"))
(should-not (textsec-mixed-numbers-p "8foo8"))
(should (textsec-mixed-numbers-p "8foo")))
;;; textsec-tests.el ends here