0
我有一个字符串,而不是字节<27>
(十六进制)来表示'
(撇号),使用三个字节<E2><80><99>
。 Firefox显示这是一个撇号,但是当通过Django的render_to_response
函数传递时,我得到’
。一些其他字符也是如此:<E2><80><A6>
表示...
(elipsis)和<E2><80><93>
而不是-
。 Firefox似乎明白这个三字节表示的名字吗?django render_to_response mimetypes
在哪里 'MYDATA' 包含字符串:
render_to_response(mytemplate, mydata, mycontext)
和
render_to_response(mytemplate, mydata, mycontext, mimetype='text/html')
作品除了奇怪的字符
render_to_response
有mimetype
参数,我也许可以使用,如果我知道我的文件的MIME类型是什么。我试过
render_to_response(mytemplate, mydata, mycontext, mimetype='application/xhtml+xml')
哪个不会抛出任何异常,它只是永远不会返回。
我有两个问题:(1)什么是我的HTML文件正在使用的字符编码的名称。 (2)mimetype
参数能否帮助我按照需要渲染它?
没有人说“打印出来”。 – 2012-04-02 22:50:18
它也无法写入以二进制打开的文件...只是试图测试它。 – Intra 2012-04-02 22:56:38
您的问题在第二个链接中回答。 – 2012-04-02 22:57:18