views:

242

answers:

3

My whole app is serving stuff in utf-8, only one page (xml) should return a ISO-8859-1 page

<?xml version="1.0" encoding="ISO-8859-1"?>

Now, how can I change the header attribute in order to have the ISO-8859-1 served.

The result of

wget --save-headers http://79.125.52.185/kdb/jobs/jobs_ch

is

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&#252;r Kundenservice

where

 f&#252;r

should be

 für

and the

 Content-Type: application/xml; charset=utf-8

should be

 Content-Type: application/xml; charset=iso-8859-1

Current Source

controller

def jobs_ch
  @jobs = ...
   render :action => 'jobs_ch', :layout => 'empty'
end

view

xml.instruct! :xml, :version=>"1.0" , :encoding => "ISO-8859-1"
xml.JOBS{
...
A: 

Sicher, dass die Daten nicht bereits URL-Codiert sind?

Möglicherweise bringts was, wenn du

CGI.unescape(string)

verwendest, für deine Daten?

Lichtamberg
ich glaube die Zeichen sind nicht das Problem, das Problem ist, dass im Header Content-Type: application/xml; charset=utf-8 steht.
Beffa
+1  A: 

Ah, I feel your pain. I solved the same problem with such an after_filter:

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

I'd edit the snippet to your needs, but I'm not sure about the encoding's Iconv code.

Leonid Shevtsov
A: 

Maybe you should try to change your webservers-encodings?

f.e. adding another charset?

see http://intertwingly.net/blog/2004/09/23/Copy-and-Paste

or maybe this:

http://www.ruby-forum.com/topic/111537

Lichtamberg