Skip to content

Commit 1ee3ad0

Browse files
authored
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
1 parent 1d731a3 commit 1ee3ad0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

leetcode_export/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def main():
229229
if not args.no_problem_statement and not os.path.exists(
230230
problem_statement_filename
231231
):
232-
with open(problem_statement_filename, "w+") as problem_statement_file:
232+
with open(problem_statement_filename, "w+", encoding='utf-8') as problem_statement_file:
233233
problem_statement_file.write(
234234
problem_statement_template.substitute(
235235
**problem_statement.__dict__
@@ -243,7 +243,7 @@ def main():
243243
)
244244
if not os.path.exists(submission_filename):
245245
logging.info(f"Writing {submission.title_slug}/{submission_filename}")
246-
sub_file = open(submission_filename, "w+")
246+
sub_file = open(submission_filename, "w+", encoding='utf-8')
247247
sub_file.write(submission.code)
248248
sub_file.close()
249249
else:

0 commit comments

Comments
 (0)