I have files encoded with UTF16 LE BOM encoding and need to alter them and save. However I could not see such encoding option in https://docs.python.org/3.10/library/codecs.html#standard-encodings
My code:
with open("file.txt", mode='w', encoding="utf_16_le") as file:
content = file.read()
function_to_replace_content(content)
file.write(content)
This saves the file without BOM. Is there an option to encode the file including BOM and save it that way?
Similar questions here didn't have quite explanatory and/or working answers.
Alright, I got this pretty quick after all: