Explicitly specify encoding when opening text files in Python code

This commit is contained in:
practicalswift
2018-06-12 17:49:20 +02:00
parent fa4b9065a8
commit 634bd97001
19 changed files with 38 additions and 38 deletions

View File

@ -146,7 +146,7 @@ def file_has_without_c_style_copyright_for_holder(contents, holder_name):
################################################################################
def read_file(filename):
return open(os.path.abspath(filename), 'r').read()
return open(os.path.abspath(filename), 'r', encoding="utf8").read()
def gather_file_info(filename):
info = {}
@ -325,13 +325,13 @@ def get_most_recent_git_change_year(filename):
################################################################################
def read_file_lines(filename):
f = open(os.path.abspath(filename), 'r')
f = open(os.path.abspath(filename), 'r', encoding="utf8")
file_lines = f.readlines()
f.close()
return file_lines
def write_file_lines(filename, file_lines):
f = open(os.path.abspath(filename), 'w')
f = open(os.path.abspath(filename), 'w', encoding="utf8")
f.write(''.join(file_lines))
f.close()