Function: puny-encode-string

puny-encode-string is a byte-compiled function defined in puny.el.gz.

Signature

(puny-encode-string STRING)

Documentation

Encode STRING according to the IDNA/punycode algorithm.

This is used to encode non-ASCII domain names. For instance, "bücher" => "xn--bcher-kva".

Source Code

;; Defined in /usr/src/emacs/lisp/net/puny.el.gz
(defun puny-encode-string (string)
  "Encode STRING according to the IDNA/punycode algorithm.
This is used to encode non-ASCII domain names.
For instance, \"bücher\" => \"xn--bcher-kva\"."
  (let ((ascii (seq-filter (lambda (char)
                             (< char 128))
                           string)))
    (if (= (length ascii) (length string))
        string
      (concat "xn--"
              (if (null ascii)
                  ""
                (concat ascii "-"))
              (puny-encode-complex (length ascii) string)))))