Mercurial > libervia-backend
diff sat_frontends/jp/cmd_forums.py @ 2608:0883bac573fd
jp (forums/edit): fixed unicode when dumping in json
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 03 Jun 2018 18:05:01 +0200 |
parents | 26edcf3a30eb |
children | 56f94936df1e |
line wrap: on
line diff
--- 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)