我遇到了由使用 sbcl 在给定 url 中使用的非拉丁 1 字符引起的错误,例如:
(drakma:http-request "http://www.youtube.com/„weird-url")
debugger invoked on a FLEXI-STREAMS:EXTERNAL-FORMAT-ENCODING-ERROR in thread
#<THREAD "initial thread" RUNNING {1002998D23}>:
#\DOUBLE_LOW-9_QUOTATION_MARK (code 8222) is not a LATIN-1 character.
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(FLEXI-STREAMS::SIGNAL-ENCODING-ERROR
#<FLEXI-STREAMS::FLEXI-LATIN-1-FORMAT (:ISO-8859-1 :EOL-STYLE :LF)
{1002F196E3}>
"~S (code ~A) is not a LATIN-1 character."
#\DOUBLE_LOW-9_QUOTATION_MARK
8222)
显然,标头被定义为由RFC2616以 Latin-1 格式发送(这是我在遇到此错误后在 github 上打开的票证),因此 URL 在传递给 drakma 之前必须正确编码。但我不知道怎么做,因为显然不可能(因为它不是 LATIN-1 字符)这样做?
我的示例的工作调用是什么(除了 URL 是伪造的并且可以缩短为http://www.youtube.com的事实)?
(drakma:http-request (magic-encoding-function "http://www.youtube.com/„weird-url"))