aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/net/puny.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/net/puny.el b/lisp/net/puny.el
index d96c6c22196..08da51b587f 100644
--- a/lisp/net/puny.el
+++ b/lisp/net/puny.el
@@ -190,6 +190,26 @@ For instance \"xn--bcher-kva\" => \"bücher\"."
190 (cl-incf i))) 190 (cl-incf i)))
191 (buffer-string))) 191 (buffer-string)))
192 192
193;; http://www.unicode.org/reports/tr39/#Restriction_Level_Detection
194
195(defun puny-highly-restrictive-p (string)
196 (let ((scripts
197 (seq-uniq
198 (seq-map (lambda (char)
199 (aref char-script-table char))
200 string))))
201 (or
202 ;; Every character uses the same script.
203 (= (length scripts) 1)
204 (seq-some 'identity
205 (mapcar (lambda (list)
206 (seq-every-p (lambda (script)
207 (memq script list))
208 scripts))
209 '((latin han hiragana kana)
210 (latin han bopomofo)
211 (latin han hangul)))))))
212
193(provide 'puny) 213(provide 'puny)
194 214
195;;; puny.el ends here 215;;; puny.el ends here