diff --git a/invesalius/reader/dicom.py b/invesalius/reader/dicom.py index f2ea447..b6109f7 100644 --- a/invesalius/reader/dicom.py +++ b/invesalius/reader/dicom.py @@ -21,7 +21,7 @@ import time #import gdcm #import vtkgdcm import sys - +import utils # In DICOM file format, if multiple values are present for the # "Window Center" (Level) and "Window Width", both attributes @@ -1926,7 +1926,7 @@ class Image(object): self.number = parser.GetImageNumber() self.spacing = spacing = parser.GetPixelSpacing() self.orientation_label = parser.GetImageOrientationLabel() - self.file = parser.filename.encode('utf-8') #Necessary original is unicode + self.file = parser.filename.encode(utils.get_system_encoding()) self.time = parser.GetImageTime() self.type = parser.GetImageType() self.size = (parser.GetDimensionX(), parser.GetDimensionY()) diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index 55c9e3b..7b1d7ec 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -105,7 +105,7 @@ class LoadDicom(threading.Thread): break reader = gdcm.Reader() - reader.SetFileName(filepath.encode('utf-8')) + reader.SetFileName(filepath.encode(utils.get_system_encoding())) if (reader.Read()): file = reader.GetFile() @@ -211,7 +211,7 @@ class LoadDicom(threading.Thread): write_png.Write() # ---------- Refactory -------------------------------------- - data_dict['invesalius'] = {'orientation_label' : GetImageOrientationLabel(filepath.encode('utf-8'))} + data_dict['invesalius'] = {'orientation_label' : GetImageOrientationLabel(filepath.encode(utils.get_system_encoding()))} # ------------------------------------------------------------- dict_file[filepath] = data_dict diff --git a/invesalius/utils.py b/invesalius/utils.py index 506f113..baab670 100755 --- a/invesalius/utils.py +++ b/invesalius/utils.py @@ -20,6 +20,7 @@ import platform import sigar import sys import re +import locale def debug(error_str): """ @@ -252,5 +253,5 @@ def get_physical_memory(): return int(mem.total()) - - +def get_system_encoding(): + return locale.getdefaultlocale()[1] -- libgit2 0.21.2