8 Replies Latest reply on Jun 21, 2015 3:08 AM by alice07

    Exporting Carriage Return LineFeed Characters in FMPA10 on Mac

    tommcin

      Title

      Exporting Carriage Return LineFeed Characters in FMPA10 on Mac

      Post

      I am trying to create a text file for input to a Windows Script.  They want a CR LF (x 0D0A) between each record.  I created CRLF_g using Code(13) & Code(10) and appended it to each line.  The control characters seem to be there using Char(field) where the fields are the last characters in the string.  But strange things happen.  Code ( last character ) displays 1000013

       

      When I export the individual records  the  last characters in each line come out as  x0B0B0D. when I view the file with HexEdit.

       

      When I concatenate all the records into one global field and export the field, I see  00 0D 00 0A at the end of each record.  This seems to be in two byte unicode as there is a  00 byte between each character.  All the hex characters match to what is in the original Filemaker databases.

       

      How can I get the 0D 0A to be inserted into an Exported text file in the single byte format.

        • 1. Re: Exporting Carriage Return LineFeed Characters in FMPA10 on Mac
          comment_1
             In plain-text formats (tab or comma-separated), carriage returns are reserved as record delimiters. Filemaker converts in-field carriage returns to vertical tabs (U+000B) when exporting to these formats.

          When you export field contents, the in-field carriage returns are preserved - but the encoding is UTF-16 and cannot be changed.

          I believe you should be able to achieve your goal by making each line a record (with no delimiting characters contained in the field), then exporting as tab-separated text using Windows (ANSI) file character set (this is assuming you are on Windows - on a Mac, Filemaker ignores its own setting).

          Alternatively, you could export as XML and use a custom XSLT stylesheet during export to build the file to your specifications - see:
          http://fmforums.com/forum/showtopic.php?tid/192649/


          • 2. Re: Exporting Carriage Return LineFeed Characters in FMPA10 on Mac
            tommcin
              

            Eventually the program will be run on Windows and then it should add an x0D0A just fine.  Nothing seems to work directly from a MAC.

             

            I see no reason why Filemaker has to mess with the codes the programmer inserts into records.  I cannot find any Filemaker documentation as to why they do what they do.  Also don't see why they insist on putting out Export Field Contents only in UTF-16.  It adds a funny character to the start of the file.  

             

            For the fun of it, I will try and see what a Windows system does with this UTF-16 file.

             

            If I need to get it right from a MAC I have just replaced all x0D with x0D0A in the basic MAC file with a hexedit program and all looks well.  If I don't want to go through this second step, it will be time to learn XML.

             

            Thanks for confirming my suspicions and providing alternatives.

             

            Tom 

            • 3. Re: Exporting Carriage Return LineFeed Characters in FMPA10 on Mac
              comment_1
                

              TomMcIn wrote:

              I see no reason why Filemaker has to mess with the codes the programmer inserts into records.  I cannot find any Filemaker documentation as to why they do what they do. 


              They have to do this, if they want to be able to import their own exports correctly. The documentation is in the help for each file format, e.g.:

              http://www.filemaker.com/help/html/import_export.16.22.html#1041694

               

               

               


              TomMcIn wrote:

               Also don't see why they insist on putting out Export Field Contents only in UTF-16.  It adds a funny character to the start of the file. 


              I don't see anything "funny" in the UTF-16 file - but I don't see why it must be UTF-16 either.



              • 4. Re: Exporting Carriage Return LineFeed Characters in FMPA10 on Mac
                tommcin
                  

                I see the changing of my internal CRs (x0D) to VTs (x0B) is necessary to identify the end of records with their own trailing CRs (x0D).  I don't see any rule that applies for converting an internal LF (x0A) to the VT (x0B).  Given these rules, I won't get a Windows compatible file from a normal Mac Export.  Expect running FM on Windows will fix the problem.

                 

                When I Export Field Contents, there is only one record so no need to protect their CRs.  The extra character at the start of the hex dump from Export Field Contents is the FE FF preceding the word cscript as in FE FF 00 63 00 73 00 63 00 72 00 69 00 70 00 74.

                Could be something of a standard.  Without the first character and the 00s, the output is perfect. 

                 

                Thanks

                Tom 


                 

                 

                • 5. Re: Exporting Carriage Return LineFeed Characters in FMPA10 on Mac
                  comment_1
                    

                  Filemaker considers CR and LF to be the same in this regard - IMHO correctly so, being a multi-platform application.

                  What isn't correct is ignoring the character set chosen for exporting: I believe that selecting Windows should result in records separated by CR+LF - but no matter what I choose, I always get CR as the record delimiter (might be different on Windows). So it isn't the rules that keep you from getting the desired result, but a bug.

                   

                   

                  As for UTF-16, that's what it's supposed to look like. The first character is the BOM, and the 2 bytes per character are what makes it 16. Without the first character and the 00s, it would be 'UTF-8, no BOM'.

                  • 6. Re: Exporting Carriage Return LineFeed Characters in FMPA10 on Mac
                    carlsson_1

                    Old thread, but same issue. 

                    I'm trying to export a text file that are supposed to be imported into a economy application. It won't work because I can't export a LF at the end of every line.

                    I need to export one text field from one record, containing a lot of information.

                    Are there any way at all to export this text field with LF on the end of every line?

                     

                    Please help...

                     

                    i'm on FM11A.

                    • 7. Re: Exporting Carriage Return LineFeed Characters in FMPA10 on Mac
                      fabricen
                       Hi, just posted a blog entry here. Finally, there is a native way with FileMaker 14 -although not as obvious as one would expect. The blog post is in French, but the file is in English and, I hope, quite understandable. http://www.1-more-thing.com/controle-des-fins-de-lignes-lf-crlf/