我目前正在爲pastie.el的精神創建一個Rest客戶端來製作博客文章。主要目標是讓我在emacs中編寫紡織品,並向Rails應用程序發佈帖子,以創建它。它工作正常,直到我用西班牙語或日語輸入任何內容,然後出現500錯誤。 pastie.el也有這個問題。在emacs中使用url elisp包創建一個POST:utf-8問題
下面是代碼:
(需要「URL)
(defun create-post()
(interactive)
(let ((url-request-method "POST")
(url-request-extra-headers '(("Content-Type" . "application/xml")))
(url-request-data (concat "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<post>"
"<title>"
"Not working with spanish nor japanese"
"</title>"
"<content>"
;; "日本語" ;; not working
;; "ñ" ;; not working either
"h1. Textile title\n\n"
"*Textile bold*"
"</content>"
"</post>"))
) ; end of let varlist
(url-retrieve "http://127.0.0.1:3000/posts.xml"
;; CALLBACK
(lambda (status)
(switch-to-buffer (current-buffer)))
)))
我現在這個問題可以固定可以想象的唯一方法是通過使emacs的編碼UTF-8字符,以便那'''變成'&#241'(順便說一下)。
什麼可以解決這個問題?
編輯:'*'不等於*'。我的意思是,如果我用emacs編碼爲UTF-8,例如'sgml-char',它會使整個文章變成utf-8編碼。像* Textile bold *因此使RedCloth無法將其轉換爲html。對不起,這是非常糟糕的解釋。
Emacs版本? application/xml沒有標題? 最後,如果*和*在連接的另一端不等價,則說明您沒有使用XML。 – jrockway 2009-08-26 07:56:13
哎。添加了xml頭。我正在使用Emacs 23.0。謝謝。 – wallyqs 2009-08-26 08:20:52
當然關於*相當於*?我從來沒有見過它,它不是XML的五個強制實體之一。如果Emacs產生這個錯誤,我會說這是一個錯誤。 – legoscia 2009-08-26 18:24:38