Contents
Karrigell默认输出-中文编码
LoYwEnG <[email protected]> reply-to [email protected] to [email protected] date Tue, Aug 5, 2008 at 16:25
subject [CPyUG:61497] Re: Karrigell的乱码问题
问题
这是lovelypython中CDay2里面的一段代码(部分): # -*- coding: utf-8 -*- def index(**args): p...
# -*- coding: utf-8 -*- def index(**args): p = KQF('fm_cdwalk','POST',"index","CD Walk") p.addHtmNode('text',"keywd","文件名",{'size':20,'maxlength':50}) p.addGroup(["submit","btn_submit","Walk it!","btn"]) p.display()
当我用firefox(Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071719 Firefox/3.0.1)浏览时,上面的“文件名”显示的是乱码。
- 看了一下character encoing,firefox使用的是Western(ISO-8859-1),自己手动改成UTF-8后就成常了,但每刷新一次又是乱码即 firefox又再次选择了Western(ISO-8859-1)。
Ubuntu8.04 Python 2.5.2
解决
自己摸索出来的,很有成就感,虽然不知道原因,但能成就好。正想想写个小结,却发现给Zoom. Quiet先写了。 不过我也要写写啦。。 文件KarrigellRequestHandler.py里面有个函数:
代码中的k_encoding_charsets.encoding2python_map原来是k_encoding_charsets.encoding2mime_map。因为我把k_config.outputEncoding(在k_config中改)改成"utf_8" ,但却发现encoding2mime_map中居然没有utf-8,而encoding2python_map有,所以就这么改过来了。
- 结果这么胡乱一改,居然可以了。
- 郁闷!Zoom.Quiet改的是Karrigell.ini。再改上面那些之前,conf下面有关encoding的都一个个改了试过了,都不行。看来是RP问题了。
最解决
- 2008/8/5 junyi sun <[email protected]>
RESPONSE['Content-Type'] = "text/html; charset=utf-8"
反馈