Page 1 of 2

Write into Text File needs a 'no BOM' option

Posted: Mon Nov 25, 2013 7:33 am
by JohnO
I am using 'Write into Text File' to write out some installer values to a 'config.properties' file, which consist of pairs of 'key=value'. When reading this file in our Java application, I was getting null returned for one of the keys. After about half a day of investigation, I discovered this was because IA had written out the UTF-8 file with the optional Byte Order Mark (BOM).

I then spent the other half of the day trying to come up with some clever way of ignoring the BOM, until the obvious, simple solution occurred to me - write out the first line of config.properties as a comment (# This is a comment).

I really think the Write to Text File should have a checkbox to control the writing of the BOM.

Incidentally, if anyone tries this, DO NOT code the value as "# This is a comment". When you build the installer, it fails with a weird message to do with this statement, but at a different line number. Basically, it thinks that "# This is a comment" is a compiler variable with a missing '#'! But, the build seemed to hang on to this, even after I changed the code. I had to revert my script from subversion to get it working.

What you have to do is to define a compiler variable to hold the comment, e.g: #COMMENT# = # This is a comment

John

Re: Write into Text File needs a 'no BOM' option

Posted: Mon Nov 25, 2013 1:11 pm
by FrancescoT
Dear John,

thank you for sharing your findings ... but anyway, I suppose that even adding an empty string is enough.

Regards

Re: Write into Text File needs a 'no BOM' option

Posted: Wed Dec 18, 2013 3:31 am
by bengtbr
In my own tests InstallAware 18 will store the UTF BOM bytes to the beginning of the text file when using the "Write into text file" command.
This also even if you have an original ANSI text file to which you append text with "write into text file". The file will change to UTF-8 after the command.
Writing a newline or comment string to the beginning of the text file doesn't help as mentioned in some postings.
Our problem was related to reading a configuration file produced by IA and in this case we have now to change the application reading the configuration file.
The BOM option would indeed have been nice in this case.
Best regards
Bengt Bredenberg

Re: Write into Text File needs a 'no BOM' option

Posted: Wed Dec 18, 2013 12:21 pm
by FrancescoT
Dera Bengt,

In fact, the suggestion was intended to be used when writing to a file ... am I missing something?

Regards

Re: Write into Text File needs a 'no BOM' option

Posted: Thu Dec 19, 2013 12:18 am
by bengtbr
Hi Francesco
My problem was and still is that when writing text to a file using "write into text file" IA
will always add the BOM characters to the beginning of the file and at the same time make the file
an UTF-file. It will also do it if I only write a $newline$ to the file. Does your comment suggest there is
another way to write text to a file than using the command "write into text file".
Bengt

Re: Write into Text File needs a 'no BOM' option

Posted: Thu Dec 19, 2013 12:43 pm
by FrancescoT
Dear Bengt,

please excuse me, but I am not sure to follow your reply ...

... are you asking if exist another way to write to a text file with IA?

If true, it is not.

Regards

Re: Write into Text File needs a 'no BOM' option

Posted: Mon Jan 06, 2014 10:30 am
by JohnO
Dear Francesco
I have now seen the same issue as bengtbr. Writing some values to an existing ascii file that is part of our app - it gets changed to UTF-8, and has the three BOM characters at the start. As my file is a Java properties file, I can work round it by making line 1 into a comment. This will not work for some files.

What IA needs is for Write-into-Text-File to have an option that controls whether the BOM should be written or not. IA introduced the use of UTF-8 in IA 16 (I think), before that, this file would have been ascii. To me it is an oversight on the part of IA development team for IA16. Especially, since the UTF-8 spec says that a BOM is optional (OK, I have seen conversations that argue the finer points of this, but for practical purposes it is optional).

I think fixing this should be a matter of some urgency.

Regards, John

Re: Write into Text File needs a 'no BOM' option

Posted: Wed Jan 08, 2014 12:03 pm
by FrancescoT
Dear John,

it is not a question of fixing it but eventually, to have this option with future IA versions.
By now, I can only post a note about to our dev team.

Regards

Re: Write into Text File needs a 'no BOM' option

Posted: Wed Jan 15, 2014 7:58 am
by JohnO
Dear Francesco
A note to your dev team is the right answer! Thanks for doing that. I hope you were able to emphasise it's urgency. Though l do understand that what looks like a small change (adding a checkbox) can be just the tip of an iceberg.

Regards, John

Re: Write into Text File needs a 'no BOM' option

Posted: Tue Mar 25, 2014 9:54 am
by JeffryPaul
This is a serious oversight for the IA developers. When writing to new text file, there must be a way to distinguish whether the file will be UTF or ANSI format.
Is this still a problem as of version 18.05? The Installaware Blog does not indicate that the problem has been resolved.
Until this is resolved, I cannot upgrade to version 18.x.

Re: Write into Text File needs a 'no BOM' option

Posted: Tue Mar 25, 2014 1:10 pm
by FrancescoT
Dear Jeffry,

Currently, the "write to text file" command only stores data using the UTF format.

As I have already said previously; it is not a question of fixing it, but instead, to have this option with future IA versions.

regards

Re: Write into Text File needs a 'no BOM' option

Posted: Sun Oct 04, 2015 6:32 am
by cancelor
I've been falling in this problem as well, as soon as I've updated to IA X2. Yes, IT IS A BUG. IA CORRUPTS an ANSI file by writing a BOM. Currently my installation program creates problems to user and I need to write to the file without using IA.

Re: Write into Text File needs a 'no BOM' option

Posted: Mon Oct 05, 2015 10:36 am
by FrancescoT
IT'S NOT A BUG!

latest InstallaAware version only writes UNICODE UTF8 files ... which are not ANSI.

Re: Write into Text File needs a 'no BOM' option

Posted: Mon Nov 14, 2016 3:51 am
by pfennig
FrancescoT wrote:Currently, the "write to text file" command only stores data using the UTF format.

As I have already said previously; it is not a question of fixing it, but instead, to have this option with future IA versions.


Several versions later this option is still not implemented. Files are still be written as UTF8 with BOM.
Since we had to do respective changes in our program code as well, I know that this part isn't a big deal.
Please, could you remind your development team to implement this feature really soon?

Re: Write into Text File needs a 'no BOM' option

Posted: Wed Nov 16, 2016 12:56 pm
by FrancescoT
Dear Pfennig,

unfortunately, I don't believe it will be implemented in future IA versions.

Regards