xsl-list
[Top] [All Lists]

Re: [xsl] Outputting UTF-8

2017-03-25 10:33:45
Hi, Martin. That is absolutely correct.
I remember now that in my testing I had used 'txt' as the extension and when I loaded it into Excel set the UTF-8 flag.
Problem solved. Face red.
Thanks,
Mark

On 3/25/2017 7:50 AM, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de wrote:
On 25.03.2017 15:39, Mark Wilson pubs(_at_)knihtisk(_dot_)org wrote:
While writing and testing my XSL stylesheet, the direct output was in
UTF-8. However, as soon as I switched to result-document, I got garbage
characters for diacritics from my original xml.  That is, for 'Zürich',
I get ' Zürich'. Except for the absence of UTF-8, everything else works
fine. I am assuming that I have declared result-document incorrectly, so
have not included the input or full stylesheet. Below is the declaration:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xs="http://www.w3.org/2001/XMLSchema"; exclude-result-prefixes="xs"
version="2.0">

    <xsl:strip-space elements="*"/>

    <xsl:template match="/">
        <xsl:for-each select="collection('../xml/?select=*.xml')">
            <xsl:apply-templates/>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="adlibXML">
        <xsl:variable name="file-name-out" select="concat('../work/',
substring-before((tokenize(document-uri(/),'/'))[last()], '.'), '.csv')"/>
        <xsl:result-document href="{$file-name-out}" encoding="UTF-8"
method="text">
            <xsl:apply-templates/>
        </xsl:result-document>
    </xsl:template>

<!-- other templates -->
</xsl:stylesheet>

Well, with a text output format like .csv I don't think there is any way the application reading the file can identify the encoding so perhaps the software you use to read or display the CSV file simply treats it as an 8-bit encoding and that way the two byte UTF-8 representation of that non-ASCII character is displayed as two separate characters. So how do you look at the CSV, can't you change the settings of that software to open as UTF-8?


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>