Function: gnus-url-unhex-string

gnus-url-unhex-string is a byte-compiled function defined in gnus-util.el.gz.

Signature

(gnus-url-unhex-string STR &optional ALLOW-NEWLINES)

Documentation

Remove %XX, embedded spaces, etc in a url.

If optional second argument ALLOW-NEWLINES is non-nil, then allow the decoding of carriage returns and line feeds in the string, which is normally forbidden in URL encoding.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-util.el.gz
;; FIXME: Make obsolete in favor of `url-unhex-string', which is
;;        identical except for the call to `char-to-string'.
(defun gnus-url-unhex-string (str &optional allow-newlines)
  "Remove %XX, embedded spaces, etc in a url.
If optional second argument ALLOW-NEWLINES is non-nil, then allow the
decoding of carriage returns and line feeds in the string, which is normally
forbidden in URL encoding."
  (let ((tmp "")
	(case-fold-search t))
    (while (string-match "%[0-9a-f][0-9a-f]" str)
      (let* ((start (match-beginning 0))
             (ch1 (url-unhex (elt str (+ start 1))))
	     (code (+ (* 16 ch1)
                      (url-unhex (elt str (+ start 2))))))
	(setq tmp (concat
		   tmp (substring str 0 start)
		   (cond
		    (allow-newlines
		     (char-to-string code))
		    ((or (= code ?\n) (= code ?\r))
		     " ")
		    (t (char-to-string code))))
	      str (substring str (match-end 0)))))
    (setq tmp (concat tmp str))
    tmp))