Jump to content

I have built CI tools in FileMaker for generating config files for services such as postgres, nginx, apache, and others


Recommended Posts

I have built CI tools in FileMaker for generating config files for services such as postgres, nginx, apache, and others. It all looks good, however the output is UTF-16 with some odd line breaks, Windows-like?

$ exa -T sites-available
sites-available
├── api.domain.tld
├── document.domain.tld
├── filemaker.domain.tld
├── graphql.domain.tld
├── rest.domain.tld
├── soap.domain.tld
├── webrtc.domain.tld
├── www.domain.tld
└── www2.domain.tld

Is there a way to set the settings for these export field contents as UTF-8 with regular unix line breaks? Even though this is written to a local folder on a workstation git handles the transfer to the server itself. Right now I have to do on a Mac or in unix/linux quite simply( published the one liner on gist: https://gist.github.com/TyrfingMjolnir/17e5f7de32ba6b36964622a2d0e1392b 😞

iconv -f UTF-16 -t UTF-8 sites-available/api.domain.tld | tr "\r" "\n"

however for Windows not necessarily that easily

 

before I do

git push

 

Edited by ggt667
Link to post
Share on other sites
9 minutes ago, ggt667 said:

Is there a way to set the settings for these export field contents as UTF-8 with regular unix line breaks?

Starting from version 16, you can control the encoding and the line endings of the exported file using the method described here:

 

Link to post
Share on other sites

You mention some workaround inside FileMaker? Similar to this one: https://filemakerhacks.com/2017/05/09/export-field-contents-update-for-fm-16/ Poor Beverly, That's not a fix, it's an insult to people's intelligence.

 

From what you write I assume there is no way to set the line breaks and encoding of the Export Field Contents?

Edited by ggt667
Link to post
Share on other sites

https://fmhelp.filemaker.com/help/18/fmp/en/#page/FMP_Help%2Ftextencode.html

As @comment indicates, we've had these functions since FM16.  Not a workaround, pure native functions.

If you were expecting to apply the encoding and line-endings as options on the export field contents dialog itself, then no. That's not how it works.

Link to post
Share on other sites
25 minutes ago, Wim Decorte said:

https://fmhelp.filemaker.com/help/18/fmp/en/#page/FMP_Help%2Ftextencode.html

As @comment indicates, we've had these functions since FM16.  Not a workaround, pure native functions.

If you were expecting to apply the encoding and line-endings as options on the export field contents dialog itself, then no. That's not how it works.

Thanks, then "AppleScript DoShellScript()" it is

If I should ever run the solution on Windows, I may look into the way you describe.

Edited by ggt667
Link to post
Share on other sites

As that's the way it's already implemented, doing the reformatting in FileMaker does not really do it better; or worse.

In which case would one ever benefit from using \r as line break and UCS-16 or UTF-16 as encoding? It makes regular text double the size.

In my case I have just below 200 nginx vhost files, there is about 20 of them pr solution and development, testing and production for each.

Edited by ggt667
Link to post
Share on other sites

I gave this( https://filemakerhacks.com/2017/05/09/export-field-contents-update-for-fm-16/ ) a shot.

Set Field[
  myTable::ExportFldContainer; TextEncode(
    GetLayoutObjectAttribute( "SomeMergeFieldObject", "content"
                            ); "utf-8"; 3 ) ]

The value of `myTable::ExportFldContainer` is "utf-8"

Also the following yields the same proceeds

Set Field[
  myTable::LayoutObjectContent; GetLayoutObjectAttribute(
    "SomeMergeFieldObject", "content" ) ]
Set Field[
  myTable::Output; TextEncode( myTable::LayoutObjectContent; "utf-8"; 3 ) ]

 

Edited by ggt667
Link to post
Share on other sites
1 hour ago, ggt667 said:

The value of `myTable::ExportFldContainer` is "utf-8"

If you have done what you describe, and the field myTable::ExportFldContainer is indeed a container field, then it will contain a file named "utf-8.txt". This file will be UTF-8 encoded and contain the content of the merged text object, with LF line endings.

--
As a side note, I am not sure why you would want to go to through the layout and export a merged field instead of remaining at the data level and export the field itself. 

 

Link to post
Share on other sites

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

×
×
  • Create New...

Important Information

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