Dun*_*yne 3 url common-lisp drakma
我有一个包含转义网址的字符串:
http%3A%2F%2Fexample.com%3Ffoo%3Dbar+baz
Run Code Online (Sandbox Code Playgroud)
我正在尝试将其解码为以下内容:
http://example.com?foo=bar+baz
Run Code Online (Sandbox Code Playgroud)
但是,我找不到Drakma导出的任何合适的功能.我可以带像这样的代码:
* url-string
"http://example.com?foo=bar+baz"
* (drakma:url-encode url-string :utf-8)
"http%3A%2F%2Fexample.com%3Ffoo%3Dbar%2Bbaz"
Run Code Online (Sandbox Code Playgroud)
......所以我认为我走在正确的轨道上.如果有人能提供正确方向的推动我会很感激:-)我正在使用SBCL 1.0.54,它是从64位Linux Mint 13上的源代码构建的.
如果它有助于澄清我正在尝试做什么,在Ruby中,我会做以下事情:
> uri_string = "http%3A%2F%2Fexample.com%3Ffoo%3Dbar+baz"
=> "http%3A%2F%2Fexample.com%3Ffoo%3Dbar+baz"
> URI.decode uri_string
=> "http://example.com?foo=bar+baz"
Run Code Online (Sandbox Code Playgroud)
Dai*_*rod 12
快速SLIME会话.
CL-USER> (ql-dist:system-apropos "url")
#<SYSTEM curly / curly-20120407-git / quicklisp 2012-05-20>
#<SYSTEM curly.test / curly-20120407-git / quicklisp 2012-05-20>
#<SYSTEM do-urlencode / do-urlencode-20120407-git / quicklisp 2012-05-20>
#<SYSTEM url-rewrite / url-rewrite-0.1.1 / quicklisp 2012-05-20>
CL-USER> (ql:quickload :do-urlencode)
Run Code Online (Sandbox Code Playgroud)
C-cC-dpdo-urlencodeRET
DO-URLENCODE:URLDECODE
Function: (not documented)
DO-URLENCODE:URLENCODE
Function: (not documented)
DO-URLENCODE:URLENCODE-MALFORMED-STRING
Type: (not documented)
DO-URLENCODE:URLENCODE-MALFORMED-STRING-STRING
Generic Function: (not documented)
CL-USER> (do-urlencode:urldecode "http%3A%2F%2Fexample.com%3Ffoo%3Dbar%2Bbaz")
"http://example.com?foo=bar+baz"
Run Code Online (Sandbox Code Playgroud)
找到了另一个解决方案,使用Quri,一个带有编码和解码实用程序的 uri 处理库(用于 uri 和参数):
(url-decode "http%3A%2F%2Fexample.com%3Ffoo%3Dbar%2Bbaz")
;; "http://example.com?foo=bar+baz"
Run Code Online (Sandbox Code Playgroud)
要安装(ql:quickload :quri),然后可选(use-package :quri)。
(我的来源:lisp-lang.org 的推荐库和awesone-cl)。