處理非Latin-1字符我遇到使用SBCL例如由在一個給定的URL中使用非Latin-1字符的錯誤:如何啓用drakma在URL
(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以拉丁-1發送(這是我在遇到此錯誤後在github中打開的票證),因此URL必須在傳遞給drakma之前進行正確編碼。但我不知道如何,因爲顯然這是不可能的(因爲它不是拉丁-1字符)這樣做?
我的例子的工作呼籲是什麼(除了URL是假的,可以縮短爲http://www.youtube.com)?
(drakma:http-request (magic-encoding-function "http://www.youtube.com/„weird-url"))
這還不是那麼應該發送將是URL正常工作: http://www.youtube.com/%e2%80%9eweird-url 但實際發出的Drakma是: GET /%25e2%2580%259eweird-url HTTP/1.1 – Sim