Skip to content

Commit

Permalink
Set ensure_ascii=False wherever json.dump is called
Browse files Browse the repository at this point in the history
It's not uncommon for json files to have unicode. This change ensures
that the unicode stays unicode and doesn't become an escape sequence.
  • Loading branch information
UmbralReaper committed Jul 9, 2021
1 parent 0316316 commit cb8241f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tools/gfx_tools/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def write_to_json(pathname: str, data: Union[dict, list]) -> None:
Write data to a JSON file
'''
with open(pathname, 'w', encoding="utf-8") as file:
json.dump(data, file)
json.dump(data, file, ensure_ascii=False)

json_formatter = './tools/format/json_formatter.cgi'
if os.path.isfile(json_formatter):
Expand Down
2 changes: 1 addition & 1 deletion tools/gfx_tools/decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

def write_to_json(pathname, data, prettify=False):
with open(pathname, "w", encoding="utf-8") as fp:
json.dump(data, fp)
json.dump(data, fp, ensure_ascii=False)

json_formatter = "./tools/format/json_formatter.cgi"
if prettify and os.path.isfile(json_formatter):
Expand Down
2 changes: 1 addition & 1 deletion tools/vehicleDef.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def writeVehicleTemplates(templates):
with open("vehicles.json", "w", encoding="utf-8") as vehicleDefJson:
json.dump(templates, vehicleDefJson, indent=4)
json.dump(templates, vehicleDefJson, indent=4, ensure_ascii=False)
print("Vehicle defs written.")


Expand Down
2 changes: 1 addition & 1 deletion tools/vehicle_reformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_data(argsDict, resource_name):
def write_to_json(pathname, data):
with open(pathname, "w", encoding="utf-8") as fp:
try:
json.dump(data, fp)
json.dump(data, fp, ensure_ascii=False)
except ValueError:
fp.write(json.dumps(data))

Expand Down
2 changes: 1 addition & 1 deletion utilities/building-utility/deconstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def complete_json_file(template_file, all_cells, remove_template=True):
with open("output_" + os.path.basename(template_file.name),
"w", encoding="utf-8") as outfile:
json.dump(json_output_list, outfile, indent=4, separators=(",", ": "),
sort_keys=True)
sort_keys=True, ensure_ascii=False)


def cli_interface():
Expand Down
2 changes: 1 addition & 1 deletion utilities/make_iso.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def tile_convert(otile, main_id, new_tile_number):
with open(new_tileset_name + '/tile_config.json', 'w', encoding="utf-8") as tile_config_json:
json.dump(
ntc, tile_config_json,
sort_keys=True, indent=2, separators=(',', ': '))
sort_keys=True, indent=2, separators=(',', ': '), ensure_ascii=False)

#TODO: replace tiles.png with first filename from json
with open(new_tileset_name + '/tileset.txt', 'w', encoding="utf-8") as new_tileset_txt_file:
Expand Down

0 comments on commit cb8241f

Please sign in to comment.