wal*_*yqs 4 url emacs elisp ruby-on-rails
我现在正在创建一个Rest客户端,用于以pastie.el的精神制作博客文章.主要目标是让我在emacs中编写一个纺织品,然后发布一个创建它的Rails应用程序.它工作正常,直到我输入任何西班牙语或日语,然后我得到500错误.pastie.el也有同样的问题.
这是代码:
(要求'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)))
)))
Run Code Online (Sandbox Code Playgroud)
我现在可以想象的唯一方法就是修复问题的方法是让emacs编码utf-8字符,这样'''变成'ñ'(顺便说一下).
什么可以解决这个问题?
编辑:'*'不等于*'.我的意思是,如果我使用例如'sgml-char'编码为utf-8,则会使整个帖子变为utf-8编码.像*Textile bold*因此使RedCloth无法将其转换为html.对不起,解释得非常糟糕.
猜测:如果设置url-request-data为,它是否有效
(encode-coding-string (concat "<?xml etc...") 'utf-8)
Run Code Online (Sandbox Code Playgroud)
代替?
没有什么可以告诉url你使用什么编码系统,所以我猜你必须自己编码你的数据.这也应该给出一个正确的Content-length标题,因为它只是来自(length url-request-data),这显然会给大多数UTF-8字符串带来错误的结果.
| 归档时间: |
|
| 查看次数: |
921 次 |
| 最近记录: |