* clispでcgi
URIのデコード・エンコードが一応完成。
感想メモ
・whileが無くてびっくり
・xyzzy lispとの微妙な差が気になる
・(alphanumericp #\あ) => T ってなんだよ!?
なのでなくてもいいような
ごもっとも。
ですが、当方はloopマクロになじみがありませんでしたので(^^;
update : 2006-03-04 (Sat) 22:47:41
感想メモ
・whileが無くてびっくり
・xyzzy lispとの微妙な差が気になる
・(alphanumericp #\あ) => T ってなんだよ!?
(defmacro while (test &body body) `(do () ((not ,test)) ,@body)) (defun uri-unreserved-char-p (c) (find c "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._~")) (defun uri-encode (str &optional (enc charset:utf-8)) (with-output-to-string (s) (with-input-from-string (in str) (let (c) (while (setf c (read-char in nil)) (cond ((uri-unreserved-char-p c) (format s "~C" c)) ((char= c #\Space) (format s "~C" #\+)) (t (format s "~{~A~}" (map 'list #'(lambda (x) (format nil "%~2,'0x" x)) (ext:convert-string-to-bytes (string c) enc)))))) ) ) )) (defun uri-decode (str &optional (enc charset:utf-8)) (let ((l nil) c c1 c2) (with-input-from-string (in str) (while (setf c (read-char in nil)) (if (char= c #\+) (setf c #\Space)) (cond ((char/= c #\%) (dolist (x (coerce (ext:convert-string-to-bytes (string c) enc) 'list)) (push x l))) (t (and (setf c1 (read-char in nil)) (setf c2 (read-char in nil)) (push (parse-integer (format nil "~C~C" c1 c2) :radix 16) l)))))) (ext:convert-string-from-bytes (make-array (length l) :initial-contents (reverse l)) enc)))
(loop while 条件式 do 実行式)
なのでなくてもいいような
ごもっとも。
ですが、当方はloopマクロになじみがありませんでしたので(^^;
update : 2006-03-04 (Sat) 22:47:41