original commit: b8579d5187ee0e3bcd0b0381716777585012dee7
This commit is contained in:
Robby Findler 2004-12-18 02:34:23 +00:00
parent 4219499861
commit 23315099d3

View File

@ -173,13 +173,11 @@
(define internal-decode
(match-lambda
[() (list)]
[(#\% char1 char2 . rest)
[(#\% (? hex-digit? char1) (? hex-digit? char2) . rest)
;; This used to consult the table again, but I think that's
;; wrong. For exmaple %2b should produce +, not a space.
(let ([num (string->number (string char1 char2) 16)])
(if num
(cons num (internal-decode rest))
(internal-decode rest)))]
(cons (string->number (string char1 char2) 16)
(internal-decode rest))]
[(char . rest)
(cons
(vector-ref table
@ -188,6 +186,11 @@
(bytes->string/utf-8
(apply bytes (internal-decode (string->list str)))))
(define (hex-digit? c)
(or (char<=? #\0 c #\9)
(char<=? #\a c #\f)
(char<=? #\A c #\F)))
;; string -> string
(define (uri-encode str)
(encode uri-encoding-vector str))