From be0e48664a4d99d89131845263aaece122c73247 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Mon, 24 Oct 2016 14:24:02 +0200 Subject: [PATCH 1/2] Remove manually specified utf-8 encoding Since SaveFile now defaults to UTF-8 --- cura/CuraApplication.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 7c45408488..ec52c7aea1 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -382,7 +382,7 @@ class CuraApplication(QtApplication): if path: instance.setPath(path) - with SaveFile(path, "wt", -1, "utf-8") as f: + with SaveFile(path, "wt") as f: f.write(data) for stack in ContainerRegistry.getInstance().findContainerStacks(): @@ -409,7 +409,7 @@ class CuraApplication(QtApplication): path = Resources.getStoragePath(self.ResourceTypes.ExtruderStack, file_name) if path: stack.setPath(path) - with SaveFile(path, "wt", -1, "utf-8") as f: + with SaveFile(path, "wt") as f: f.write(data) From bfec96f58425517cb89fa91d4c41a085fa515c70 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Mon, 24 Oct 2016 14:24:49 +0200 Subject: [PATCH 2/2] Set encoding to utf-8 when writing files Since we assume utf-8 in a lot of places. Contributes to CURA-2692 --- .../RemovableDriveOutputDevice/RemovableDriveOutputDevice.py | 2 +- plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py index 8b6dce8292..3bd957ec5e 100644 --- a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py +++ b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py @@ -67,7 +67,7 @@ class RemovableDriveOutputDevice(OutputDevice): try: Logger.log("d", "Writing to %s", file_name) # Using buffering greatly reduces the write time for many lines of gcode - self._stream = open(file_name, "wt", buffering = 1) + self._stream = open(file_name, "wt", buffering = 1, encoding = "utf-8") job = WriteMeshJob(writer, self._stream, node, MeshWriter.OutputMode.TextMode) job.setFileName(file_name) job.progress.connect(self._onProgress) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py index 2053b8acf9..4491a00d3d 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py @@ -111,7 +111,7 @@ class MachineInstance: user_profile_file = os.path.join(user_storage, urllib.parse.quote_plus(self._name) + "_current_settings.inst.cfg") if not os.path.exists(user_storage): os.makedirs(user_storage) - with open(user_profile_file, "w") as file_handle: + with open(user_profile_file, "w", encoding = "utf-8") as file_handle: user_profile.write(file_handle) version_upgrade_manager.upgradeExtraFile(user_storage, urllib.parse.quote_plus(self._name), "user")