# HG changeset patch # User Goffi # Date 1528041901 -7200 # Node ID 0883bac573fdea2439114ddde9c439d65bdff5c4 # Parent 4c086cf7af6602e7275c5a99b678c2f28d0fb0b8 jp (forums/edit): fixed unicode when dumping in json diff -r 4c086cf7af66 -r 0883bac573fd sat_frontends/jp/cmd_forums.py --- a/sat_frontends/jp/cmd_forums.py Sun Jun 03 13:54:35 2018 +0200 +++ b/sat_frontends/jp/cmd_forums.py Sun Jun 03 18:05:01 2018 +0200 @@ -24,6 +24,7 @@ from sat_frontends.jp import common from sat.tools.common.ansi import ANSI as A from functools import partial +import codecs import json __commands__ = ["Forums"] @@ -69,7 +70,9 @@ if forums_json: # we loads and dumps to have pretty printed json forums = json.loads(forums_json) - json.dump(forums, content_file_obj, ensure_ascii=False, indent=4) + # cf. https://stackoverflow.com/a/18337754 + f = codecs.getwriter('utf-8')(content_file_obj) + json.dump(forums, f, ensure_ascii=False, indent=4) content_file_obj.seek(0) self.runEditor("forums_editor_args", content_file_path, content_file_obj)