我的整个应用程序都在utf-8中提供服务,只有一页(xml)应该返回ISO-8859-1页面
<?xml version="1.0" encoding="ISO-8859-1"?>
现在,如何更改标头属性以便提供ISO-8859-1。
的结果
wget --save-headers http://79.125.52.185/kdb/jobs/jobs_ch
是
HTTP/1.0 200 OK
...
Content-Length: 34899
Status: 200 OK
Content-Type: application/xml; charset=utf-8
...
<?xml version="1.0" encoding="ISO-8859-1"?>
<JOBS>
<INSERATE>
<INSERAT>
<ORGANISATIONID>10</ORGANISATIONID>
<INSERATID>1532</INSERATID>
<VORSPANN>Gemeinsam mit Ihrem Team sorgen Sie für Kundenservice
其中
für
应该是
für
和
Content-Type: application/xml; charset=utf-8
应该是
Content-Type: application/xml; charset=iso-8859-1
当前来源
控制器
def jobs_ch
@jobs = ...
render :action => 'jobs_ch', :layout => 'empty'
end
视图
xml.instruct! :xml, :version=>"1.0" , :encoding => "ISO-8859-1"
xml.JOBS{
...
答案 0 :(得分:1)
after_filter :this_xml_needs_to_be_in_cp1251
def this_xml_needs_to_be_in_cp1251
response.charset = 'cp1251'
response.body = Iconv.conv('cp1251//IGNORE//TRANSLIT','UTF-8',response.body)
end
我会根据您的需要编辑代码段,但我不确定编码的Iconv代码。
答案 1 :(得分:0)
Sicher,dass die Daten nicht bereits URL-Codiert sind?
Möglicherweise带来了,wenn duCGI.unescape(string)
verwendest,fürdeineDaten?
答案 2 :(得分:0)