Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Niels Kristiansen 166 posts 382 karma points
    Feb 29, 2012 @ 16:54
    Niels Kristiansen
    0

    updated: UTF-8 for danish characters in Change Output

    Hi,

    I'm using this excellent little piece of tool to fix a download for a CSV file, but it will not save it with the right charset, so æ, ø and å is changed to wierd characters.

    What do I miss to get it up running with danish characters? It works if I just save the source as .csv

    Here is the code I use:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:gecko="urn:gecko-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets gecko">
    <xsl:output method="text" indent="no" encoding="UTF-8" />


    <msxml:script language="CSharp" implements-prefix="gecko">
    <msxml:assembly name="System.Web" />
    <msxml:using namespace="System.Web" />

    <![CDATA[
    public void changeOutPut(String ContentType, String FileName) {
    HttpContext.Current.Response.ContentType = ContentType;
    HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + FileName);
    }
    ]]>

    </msxml:script>


    <xsl:param name="currentPage"/>
    <xsl:variable name="fileName">
    <xsl:choose>
    <xsl:when test="string-length(umbraco.library:Request('filename')) &gt; 0">
    <xsl:value-of select="umbraco.library:Request('filename')"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:text>defaultFilename.extension</xsl:text>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>

    <xsl:template match="/">
    <xsl:value-of select="gecko:changeOutPut('text/csv',$fileName)" />
    </xsl:template>

    </xsl:stylesheet>

     

    Hopefully someone can help me out :)

    Thanks so much.

     

    Kind regads,

    Niels

  • Niels Kristiansen 166 posts 382 karma points
    Feb 29, 2012 @ 17:42
    Niels Kristiansen
    0

    Hmm, looking like the file generated actually are utf-8, when opened in example Coda and worked without any problems in Numbers. I guess it is Excel then. *sigh*

Please Sign in or register to post replies

Write your reply to:

Draft