You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the method 'replaceInFiles' (Template.fs) to patch my configurations files. The files need to be encoded in UTF8 without BOM. When using replaceInFiles the encoding of the File is changed from UTF8 without BOM to UTF8 with BOM.
This happens because of the default encoding in the File-Module is UTF8.
Repro steps
create a file encoded with UTF8 without BOM
use the replaceInFiles to replace anything in the file
The encoding of the file is now UTF8 with BOM.
Expected behavior
Using replaceInFiles should not change the encoding of the file.
Suggested Solution
Since the methods in the File-Module use the method 'getEncoding' to detect the encoding of existing files and the encoding UTF8 with a BOM can be detected. The default encoding should be UTF8 without BOM. This would prevent a change of the file encoding of files encoded in UTF8 without BOM.
I am aware of the fact that this change could cause problems for other people if they are writing new files because the encoding of new Files would change to UTF8 without BOM.
Workaround
Rewriting the file with the encoding UTF8 without BOM after using 'replaceInFiles' solves the problem for me.
The text was updated successfully, but these errors were encountered:
Yes I agree that replaceInFiles shouldn't change the existing encoding (just like other helpers don't by default). This is definitely a bugfix and a PR would be welcome and merged.
Description
I am using the method 'replaceInFiles' (Template.fs) to patch my configurations files. The files need to be encoded in UTF8 without BOM. When using replaceInFiles the encoding of the File is changed from UTF8 without BOM to UTF8 with BOM.
This happens because of the default encoding in the File-Module is UTF8.
Repro steps
The encoding of the file is now UTF8 with BOM.
Expected behavior
Using replaceInFiles should not change the encoding of the file.
Suggested Solution
Since the methods in the File-Module use the method 'getEncoding' to detect the encoding of existing files and the encoding UTF8 with a BOM can be detected. The default encoding should be UTF8 without BOM. This would prevent a change of the file encoding of files encoded in UTF8 without BOM.
I am aware of the fact that this change could cause problems for other people if they are writing new files because the encoding of new Files would change to UTF8 without BOM.
Workaround
Rewriting the file with the encoding UTF8 without BOM after using 'replaceInFiles' solves the problem for me.
The text was updated successfully, but these errors were encountered: