From 1ee3ad0792b9b4be62b3012f7d9576e0e91eff48 Mon Sep 17 00:00:00 2001 From: YasirAkbal <81110876+YasirAkbal@users.noreply.github.com> Date: Thu, 20 Nov 2025 13:29:04 +0300 Subject: [PATCH 1/2] Specify UTF-8 encoding for file writes Some problem statements contain special characters and writing them to the file throws an error. This PR fixes this problem --- leetcode_export/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/leetcode_export/__main__.py b/leetcode_export/__main__.py index 18bf628..f4b2572 100644 --- a/leetcode_export/__main__.py +++ b/leetcode_export/__main__.py @@ -229,7 +229,7 @@ def main(): if not args.no_problem_statement and not os.path.exists( problem_statement_filename ): - with open(problem_statement_filename, "w+") as problem_statement_file: + with open(problem_statement_filename, "w+", encoding='utf-8') as problem_statement_file: problem_statement_file.write( problem_statement_template.substitute( **problem_statement.__dict__ @@ -243,7 +243,7 @@ def main(): ) if not os.path.exists(submission_filename): logging.info(f"Writing {submission.title_slug}/{submission_filename}") - sub_file = open(submission_filename, "w+") + sub_file = open(submission_filename, "w+", encoding='utf-8') sub_file.write(submission.code) sub_file.close() else: From c5a0ab686867a639cf4b2a6715c9f3b69dfceafb Mon Sep 17 00:00:00 2001 From: YasirAkbal Date: Fri, 21 Nov 2025 12:40:24 +0300 Subject: [PATCH 2/2] black formatting is done --- leetcode_export/__main__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/leetcode_export/__main__.py b/leetcode_export/__main__.py index f4b2572..ecfd26c 100644 --- a/leetcode_export/__main__.py +++ b/leetcode_export/__main__.py @@ -229,7 +229,9 @@ def main(): if not args.no_problem_statement and not os.path.exists( problem_statement_filename ): - with open(problem_statement_filename, "w+", encoding='utf-8') as problem_statement_file: + with open( + problem_statement_filename, "w+", encoding="utf-8" + ) as problem_statement_file: problem_statement_file.write( problem_statement_template.substitute( **problem_statement.__dict__ @@ -243,7 +245,7 @@ def main(): ) if not os.path.exists(submission_filename): logging.info(f"Writing {submission.title_slug}/{submission_filename}") - sub_file = open(submission_filename, "w+", encoding='utf-8') + sub_file = open(submission_filename, "w+", encoding="utf-8") sub_file.write(submission.code) sub_file.close() else: