Jump to content

CR/LF in output to Windows


Kurt Hansen
 Share

This topic is 2255 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I'm using &#0x0D; and &#0x0A; for CR/LF in a script for export in CSV-format which is to be imported in a Windows based system. The receiver on the other side of the fence tells me that these codes are wrong. His best guess are 
 and 
 but everything is open for other suggestions. When my CSV are opened in Excel Win there are double LF. I encolse a copy of the file.

Mac with El Capitan and Filemaker 11 Pro Advanced 11.0v4.

My current script:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fmp="http://www.filemaker.com/fmpxmlresult">

<xsl:output method="text" encoding="ISO-8859-1"/>

<xsl:variable name="CRLF">
<xsl:text>&#x000D;&#x000A;</xsl:text>
</xsl:variable>

<xsl:variable name="delimiter">
    <xsl:text>;</xsl:text>
</xsl:variable>

<xsl:template match="/">
    <xsl:text>EAN;Katalognr;Pladeselskab;Kunstnernavn;Titel;Komponist;Artikeltype;Listepris;Releasedato;Kontrakt&#x000D;&#x000A;</xsl:text>

<xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
    <xsl:for-each select="fmp:COL">
        <xsl:value-of select="fmp:DATA"/>
        <xsl:choose>
            <xsl:when test="position()=last()">
                <xsl:value-of select="$CRLF"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$delimiter"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:for-each>
</xsl:for-each>

<xsl:variable name="date" select="fmp:COL[9]/fmp:DATA"/>
<xsl:value-of select="substring-after(substring-after($date, '/'), '/')"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring-before(substring-after($date, '/'), '/')"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring-before($date, '/')"/>

</xsl:template>
</xsl:stylesheet>

test.csv

Edited by Kurt Hansen
Link to comment
Share on other sites

Does it work using:

<xsl:variable name="newline">
<xsl:text>&#10;</xsl:text>
</xsl:variable>

?

Edited by ggt667
Link to comment
Share on other sites

7 hours ago, Kurt Hansen said:

When my CSV are opened in Excel Win there are double LF.

That may be an Excel issue. I opened your file in a text editor and I see (only) a CRLF separating the lines. A hex dump shows 74 0D 0A 38 (i.e. "t, CR, LF, 8") at the first line break.

 

7 hours ago, Kurt Hansen said:

His best guess are &#xD; and &#xA;

&#x000D; and &#xD; are exactly the same thing - and so is &#13;.

 

7 hours ago, Kurt Hansen said:

everything is open for other suggestions.

Try using only LF as the line separator?

 

6 hours ago, ggt667 said:

<xsl:text>&10;</xsl:text>

That cannot work and will produce an error.

 

Edited by comment
Link to comment
Share on other sites

2 hours ago, comment said:
2 hours ago, comment said:

That cannot work and will produce an error.

Sorry, typo should be: <xsl:text>&#10;</xsl:text>

Link to comment
Share on other sites

  • 4 weeks later...

If you are exporting from FileMaker I doubt the encoding should be: <xsl:output method="text" encoding="ISO-8859-1"/>

At least I have used:<xsl:output method="text" encoding="UTF-8"/> for FileMaker 5 and up, I doubt there is anything that uses ISO-8859-n after Windows 2000, MacOS X and linux was released.

Edited by ggt667
Link to comment
Share on other sites

1 hour ago, comment said:

And it has nothing to do with the problem.

True, but it makes me wonder if there is something really old being worked on. An this could be a part of the path to finding the actual issue.

The simplest way to solve the issue is to make a text file on the destination system and find out which line break is used

The attached example clearly uses the CRLF as pr <xsl:text>&#x000D;&#x000A;</xsl:text>

xxd /home/user/99415-crlf-in-output-to-windows//test.csv | head -n 7 | tail -n 1
00000060: 6b74 0d0a 3830 3134 3339 3935 3030 3532  kt..801439950052

On the Mac newline is clearly: #10 or #x0A

$ echo "" | xxd
00000000: 0a                                       .

I have tested the test.csv file from initial post in LibreOffice, and OpenOffice and I see no such symptoms as described. Makes me think it's an old Windows or Office.

Edited by ggt667
Link to comment
Share on other sites

This topic is 2255 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.