From caddcaf80773cf4005f4446bd1b560fbe3fa0369 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:18:21 -0800 Subject: [PATCH] Forces JSON files to be written as UTF-8, and disables the ensure ASCII option which escapes non-ASCII chars (#4574) --- .../management/commands/document_exporter.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.py index ff200a8f5..05c78ea08 100644 --- a/src/documents/management/commands/document_exporter.py +++ b/src/documents/management/commands/document_exporter.py @@ -396,20 +396,31 @@ class Command(BaseCommand): notes, ), ) - manifest_name.write_text(json.dumps(content, indent=2)) + manifest_name.write_text( + json.dumps(content, indent=2, ensure_ascii=False), + encoding="utf-8", + ) if manifest_name in self.files_in_export_dir: self.files_in_export_dir.remove(manifest_name) # 4.1 write manifest to target folder manifest_path = (self.target / Path("manifest.json")).resolve() - manifest_path.write_text(json.dumps(manifest, indent=2)) + manifest_path.write_text( + json.dumps(manifest, indent=2, ensure_ascii=False), + encoding="utf-8", + ) if manifest_path in self.files_in_export_dir: self.files_in_export_dir.remove(manifest_path) # 4.2 write version information to target folder version_path = (self.target / Path("version.json")).resolve() version_path.write_text( - json.dumps({"version": version.__full_version_str__}, indent=2), + json.dumps( + {"version": version.__full_version_str__}, + indent=2, + ensure_ascii=False, + ), + encoding="utf-8", ) if version_path in self.files_in_export_dir: self.files_in_export_dir.remove(version_path)