Forum

Posted by
Pontus Östlund  -  December 2008
I noticed something strange:

I create an XML document (for download) and the document is UTF-8 encoded. Everything works fine when I download the document from my editarea, but as soon as I leave the editarea it fails. åäö-chars gets screwed up.

My XSL output looks like

<xsl:output
  method="xml"
  media-type="text/xml"
  indent="no"
  encoding="utf-8"
/>

And then i add some headers:

<header name="Content-Type" value="application/vnd.ms-excel; charset=utf-8" />
<header name="Content-Disposition" value="attachment; filename=julfest.xml" />

Why is it it's working when downloaded from the editarea but not when downloaded from the normal site workarea?
 
Posted by
Peter Jönsson  -  December 2008
Tricky ones...
Are there any difference in the served http-headers? If not, try adding a <charset out="utf-8"/> tag your template.
 
Posted by
Pontus Östlund  -  December 2008
Tricky ones...
Are there any difference in the served http-headers? If not, try adding a <charset out="utf-8"/> tag your template.


Great :)
It worked when I did like this:

<?xml version='1.0' encoding="iso-8859-1"?>
<xsl:stylesheet ...>
  <xsl:output
    method="xml"
    media-type="text/xml"
    indent="no"
    encoding="iso-8859-1"
  />
  <xsl:template match="/">
    <charset out="utf-8"/>
    <header name="Content-Type" value="application/vnd.ms-excel" />
    <header name="Content-Disposition" value="attachment; filename=julfest.xls" />
    ...
  </xsl:template>
</xsl:stylesheet>
 
Posted by
Peter Jönsson  -  December 2008
Nice that it worked ;)

Don't really get the latin1 references in the xml-header and the stylesheet tag though. Didn't it work without them?

If I have got this right the cause of the problem most likely is that your filesystem settings (under CE->Configuration->languages) is set to save files in latin1 for your language (or for the no-language option). Roxen knows this and converts the file on disk to its internal format for procesing. After processing it is converted to the previous format and served - but of course the http-headers might still be altered with the <header>-tag as you wish. When the served data and its charset headers doesn't match you might get strange stuff with at least the so called extended chars.

When served as a logged in editor I _think_ that all files are served by the settings for the edit-environment (which serves files correctly according the that environment and made your xls file come out right). Luckily enough rxml provides the <charset> tag to convert output anyway we want in "normal" context to (but we still have to know exactly when and where to use it. Ouch :)

If I remember correctly Roxen 5 will change the default lang settings to have everything saved on disk as utf-8 and hence hopefully make life a little easier
 
Posted by
Pontus Östlund  -  December 2008
Don't really get the latin1 references in the xml-header and the stylesheet tag though. Didn't it work without them?


I altered them back and forth a couple of times. It only worked, in my edit area, when they were "UTF-8".

The reference in the XML header is, in this case, mostly for JEdit that automatically converts the charset encoding of the file to the one in the XML header.

 
1
Search this thread: