I'm using some Regex to perform text edits on the contents of a plain text ini file.
However, when these changes are saved, it is altering the format of my Unicode BOM ini files and turning them into ANSI.
Code: Select all
FileDelete, TestINI_New.ini FileRead, AllFile, TestINI.ini FileAppend, % RegExReplace(AllFile, "`amsU)(?<=\[Recent\])(.*)(?=^\[\w+]$)","`n`n`n$2"), TestINI_New.ini run, TestINI_New.ini
I have found a thread where it was suggested that adding , UTF-8 to the and of a FileAppend would save as Unicode. However, I don't want to force all ini files (even if they were in ANSI to begin with) to be saved as Unicode. I only want the files that are already Unicode to be saved as Unicode.
How can adapt the above code example so that the existing format of the ini file is retained (regardless of whether it's ANSI or UNICODE BOM) after the FileAppend command has altered it and saved the changes?