首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

post请求中内容有中文字符怎么办

2012-02-22 
post请求中内容有中文字符怎么处理如题,例如:$response$ua- request(POSThttp://xxxx.om/Save.do ,Conte

post请求中内容有中文字符怎么处理
如题,例如:
$response   =   $ua-> request(POST   'http://xxxx.om/Save.do ',
                                                'Content-Type '                                 =>   'application/x-www-form-urlencoded ',
                                                'Accept-Encoding '                 =>   'gzip,   deflate ',
                                                'Cache-Control '                                 =>   'no-cache ',
                                                'Content '                                 =>   [ 'hidState '                                     =>   'saveBack ',
                                                                                                                'txtDate '                 =>   "$mydate ",
                                                                                                                'txtTask '                 =>   '中文字符 ',]);#这样发送过去的数据都是???

请教如何处理中文字符

[解决办法]
'%E6%B5%8B%E8%AF%95 ' 是utf-8编码, %B2%E2%CA%D4是gbk编码, 客户端在windows平台上?
如果填表页面的content-typ中有utf-8的话, 那么浏览器会自动设置中文编码为utf-8上传.
而你自己写的这个程序就没有这种能力.
所以可以用程序先将中文转换成utf-8再送出去.
可以考虑用Text::Iconv

use Text::Iconv;
$a = Text::Iconv-> new( "gbk ", "utf-8 ")-> convert( "我 ");

...
$txtTask => $a


热点排行