Karrigell的乱码问题

15 views
Skip to first unread message

LoYwEnG

unread,
Aug 4, 2008, 11:01:21 PM8/4/08
to python-cn`CPyUG`华蟒用户组
这是lovelypython中CDay2里面的一段代码(部分):
# -*- 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()
KQF是Karrigell_QuickForm

当我用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

LoYwEnG

unread,
Aug 4, 2008, 11:02:51 PM8/4/08
to python-cn`CPyUG`华蟒用户组
我想知道这是哪里的问题,是firefox还是Karrigell......

huliuhe

unread,
Aug 4, 2008, 11:06:31 PM8/4/08
to pyth...@googlegroups.com
应该是Karrigell. 生成的html 里面声明了编码为 Western(ISO-8859-
1) 。 所以一刷新,firefox 就选择 Western(ISO-8859-
1)


2008/8/5 LoYwEnG <LoY...@gmail.com>

Moyan

unread,
Aug 5, 2008, 12:07:44 AM8/5/08
to python-cn`CPyUG`华蟒用户组
保存代码的时候选择 utf-8编码




On 8月5日, 上午11时06分, huliuhe <huli...@gmail.com> wrote:
> 应该是Karrigell. 生成的html 里面声明了编码为 Western(ISO-8859-1) 。 所以一刷新,firefox 就选择
> Western(ISO-8859-1)
>
> 2008/8/5 LoYwEnG <LoYw...@gmail.com>

LoYwEnG

unread,
Aug 5, 2008, 3:28:57 AM8/5/08
to pyth...@googlegroups.com
用浏览器查看的html源代码中 <meta content="text/html; charset=UTF-8"
http-equiv="Content-Type">
ks文件开头声明 # -*- encoding: utf-8 -*
firefox默认的编码改成utf-8也不行。。


2008/8/5 Moyan <ghi...@gmail.com>:

--
正正正正正

Zoom.Quiet

unread,
Aug 5, 2008, 3:58:18 AM8/5/08
to pyth...@googlegroups.com
2008/8/5 LoYwEnG <LoY...@gmail.com>:


Karrigell 有新的配置项了...as atta.

--

http://zoomquiet.org'''
过程改进乃是催生可促生靠谱的人的组织!
PE keeps evolving organizations which promoting people be good!'''

2008-08-05-155848_685x253_scrot.png

LoYwEnG

unread,
Aug 5, 2008, 4:25:24 AM8/5/08
to pyth...@googlegroups.com
谢谢各位了。
下午本来是练听力来着,但一看到那乱码就不爽,这下停不下来了。不过现在总算可以了。
自己摸索出来的,很有成就感,虽然不知道原因,但能成就好。正想想写个小结,却发现给Zoom. Quiet先写了。
不过我也要写写啦。。
文件KarrigellRequestHandler.py里面有个函数:
def content_type():
   "return content type for html texts"
   if not k_config.output_encoding:
       ct="text/html"
   else:
       ct="text/html; charset="+k_encoding_charsets.encoding2python_map.get(  
           k_config.output_encoding, k_config.output_encoding)
       #encoding2mime_map
   return ct
代码中的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 Zoom. Quiet <zoom....@gmail.com>:

Zoom.Quiet

unread,
Aug 5, 2008, 5:40:02 AM8/5/08
to pyth...@googlegroups.com
2008/8/5 LoYwEnG <loy...@gmail.com>:

> 谢谢各位了。
> 下午本来是练听力来着,但一看到那乱码就不爽,这下停不下来了。不过现在总算可以了。
> 自己摸索出来的,很有成就感,虽然不知道原因,但能成就好。正想想写个小结,却发现给Zoom. Quiet先写了。
> 不过我也要写写啦。。
> 文件KarrigellRequestHandler.py里面有个函数:
> def content_type():
> "return content type for html texts"
> if not k_config.output_encoding:
> ct="text/html"
> else:
> ct="text/html; charset="+k_encoding_charsets.encoding2python_map.get(
>
> k_config.output_encoding, k_config.output_encoding)
> #encoding2mime_map
> return ct
> 代码中的k_encoding_charsets.encoding2python_map原来是k_encoding_charsets.encoding2mime_map。因为我把k_config.outputEncoding(在k_config中改)改成"utf_8"
> ,但却发现encoding2mime_map中居然没有utf-8,而encoding2python_map有,所以就这么改过来了。
> 结果这么胡乱一改,居然可以了。
收录!
http://wiki.woodpecker.org.cn/moin/MiscItems/2008-08-05

> 郁闷!Zoom.Quiet改的是Karrigell.ini。再改上面那些之前,conf下面有关encoding的都一个个改了试过了,都不行。看来是RP问题了。

不用郁!俺也是修订了没有作用的!看来是BUG了!
原先,俺发现这问题后,解决方式是:
页面中使用 E文!
咔咔咔!

junyi sun

unread,
Aug 5, 2008, 6:27:28 AM8/5/08
to pyth...@googlegroups.com
RESPONSE['Content-Type'] = "text/html; charset=utf-8"

这样应该没问题

Zoom.Quiet

unread,
Aug 5, 2008, 8:39:25 AM8/5/08
to pyth...@googlegroups.com
2008/8/5 junyi sun <ccn...@gmail.com>:

> RESPONSE['Content-Type'] = "text/html; charset=utf-8"
>
这招有效! Karrigell 2.3.5 之后版本都有效!
不过,配置文件没有反应的确是问题!
Reply all
Reply to author
Forward
0 new messages