From 001d4d9ed70451c18c98bd8ce57f0eb1820fea8d Mon Sep 17 00:00:00 2001 From: ankraft <an.kraft@gmail.com> Date: Thu, 18 Apr 2024 22:53:31 +0200 Subject: [PATCH] Open input file in error-replace mode to ignore and replace unknown character --- toMkdocs/toMkdocs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toMkdocs/toMkdocs.py b/toMkdocs/toMkdocs.py index d0cb9ad..1ee9eeb 100644 --- a/toMkdocs/toMkdocs.py +++ b/toMkdocs/toMkdocs.py @@ -133,7 +133,9 @@ def analyseMarkdown(filename:str) -> list[Clause]: print(f'[green]Analyzing "{filename}"') - with open(filename, 'r') as file: + # Read the file. + # Note: We use utf-8 and replace errors to avoid problems with special or unknown characters. + with open(filename, 'r', encoding = 'utf-8', errors = 'replace') as file: inLines = file.readlines() outClauses:list[Clause] = [Clause(0, '', '', [])] -- GitLab