url-encode-string

Name

url-encode-string -- Returns str with all special characters %-encoded

Synopsis

(url-encode-string str)

Description

Converts str to a properly encoded URL string. Returns str unchanged if it is not a string.

Author

Norman Walsh, <ndw@nwalsh.com>

Source Code

(define (url-encode-string str)
  ;; Returns str with all special characters %-encoded
  (if (string? str)
      (let loop ((charlist (string->list str)) (url ""))
	(if (null? charlist)
	    url
	    (loop (cdr charlist) 
		  (string-append url (url-encode-char (car charlist))))))
      str))