Skip to content

Commit

Permalink
Read and write file in binary mode to remove BOM (Byte Order Mark) bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
arisktfx committed Oct 29, 2024
1 parent da3e7c2 commit ec78644
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openformats/formats/docx.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def get_document(self):
with io.open(self.__document_path, 'r') as f:
self.__document = f.read()

if "\ufeff" in self.__document:
# Remove BOM
self.__document = self.__document.replace("\ufeff", "")

return self.__document

def set_document(self, document):
Expand Down

0 comments on commit ec78644

Please sign in to comment.