add encoding utf-8 with open()

This commit is contained in:
anzawatta 2018-06-25 22:48:58 +09:00
parent 0ab382f4a7
commit 61bc8cc74d
2 changed files with 2 additions and 2 deletions

View file

@ -331,7 +331,7 @@ def ablog_post(filename, title=None, **kwargs):
# read the file, and add post directive # read the file, and add post directive
# and save it # and save it
else: else:
with open(filename, 'w') as out: with open(filename, 'w', encoding='utf-8') as out:
post_text = POST_TEMPLATE % pars post_text = POST_TEMPLATE % pars
out.write(post_text) out.write(post_text)

View file

@ -655,7 +655,7 @@ def generate_atom_feeds(app):
if not os.path.isdir(parent_dir): if not os.path.isdir(parent_dir):
os.makedirs(parent_dir) os.makedirs(parent_dir)
with open(feed_path, 'w') as out: with open(feed_path, 'w', encoding='utf-8') as out:
feed_str = feed.to_string() feed_str = feed.to_string()
try: try:
out.write(feed_str.encode('utf-8')) out.write(feed_str.encode('utf-8'))