Commit d181366d authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Add a new function to say whether a string is restrictive

* puny.el (puny-highly-restrictive-p): New function.
parent 5fcbeaf6
......@@ -190,6 +190,26 @@ For instance \"xn--bcher-kva\" => \"bücher\"."
(cl-incf i)))
(defun puny-highly-restrictive-p (string)
(let ((scripts
(seq-map (lambda (char)
(aref char-script-table char))
;; Every character uses the same script.
(= (length scripts) 1)
(seq-some 'identity
(mapcar (lambda (list)
(seq-every-p (lambda (script)
(memq script list))
'((latin han hiragana kana)
(latin han bopomofo)
(latin han hangul)))))))
(provide 'puny)
;;; puny.el ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment