TableOfContents

Include(ZPyUGnav)

Karrigell中文编码

LoYwEnG <[email protected]>
reply-to        [email protected]
to      [email protected]
date    Tue, Aug 5, 2008 at 16:25

subject [CPyUG:61497] [http://groups.google.com/group/python-cn/browse_thread/thread/0b4024809918e1cf/146ca8ce51e8a5f7#146ca8ce51e8a5f7 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()

Ubuntu8.04
Python 2.5.2

解决

自己摸索出来的,很有成就感,虽然不知道原因,但能成就好。正想想写个小结,却发现给Zoom. Quiet先写了。 不过我也要写写啦。。 文件KarrigellRequestHandler.py里面有个函数:

   1 def content_type():
   2    "return content type for html texts"
   3    if not k_config.output_encoding:
   4        ct="text/html"
   5    else:
   6        ct="text/html; charset="+k_encoding_charsets.encoding2python_map.get(  
   7            k_config.output_encoding, k_config.output_encoding)
   8        #encoding2mime_map
   9    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有,所以就这么改过来了。


反馈

创建 by -- ZoomQuiet [DateTime(2008-08-05T09:38:37Z)]

PageComment2

[:/PageCommentData:PageCommentData]