Encode JSON cache as UTF-8.
This commit is contained in:
parent
7f1e136d8b
commit
cfac0f40f1
1 changed files with 4 additions and 2 deletions
|
@ -2,6 +2,8 @@
|
||||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||||
# Copyright (C) 2016 Tobias Gruetzmacher
|
# Copyright (C) 2016 Tobias Gruetzmacher
|
||||||
import json
|
import json
|
||||||
|
import codecs
|
||||||
|
|
||||||
from dosagelib.util import unescape, asciify
|
from dosagelib.util import unescape, asciify
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,13 +24,13 @@ def capfirst(text):
|
||||||
|
|
||||||
def save_result(res, json_file):
|
def save_result(res, json_file):
|
||||||
"""Save result to file."""
|
"""Save result to file."""
|
||||||
with open(json_file, 'wb') as f:
|
with codecs.open(json_file, 'wb', 'utf-8') as f:
|
||||||
json.dump(res, f, sort_keys=True, indent=2, separators=(',', ': '))
|
json.dump(res, f, sort_keys=True, indent=2, separators=(',', ': '))
|
||||||
|
|
||||||
|
|
||||||
def load_result(json_file):
|
def load_result(json_file):
|
||||||
"""Load contents of a json file."""
|
"""Load contents of a json file."""
|
||||||
with open(json_file, "rb") as f:
|
with codecs.open(json_file, 'rb', 'utf-8') as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue