Commit c733b2405355831a695dd5ee8ea908dd05b68e43

Authored by Paulo Henrique Junqueira Amorim
1 parent 577a698f

FIX: Fixed problem with unicode in DICOM gender field

Showing 1 changed file with 8 additions and 1 deletions   Show diff stats
invesalius/reader/dicom.py
@@ -1224,7 +1224,14 @@ class Parser(): @@ -1224,7 +1224,14 @@ class Parser():
1224 return "" 1224 return ""
1225 1225
1226 if (data): 1226 if (data):
1227 - return str(data) 1227 + name = data.strip()
  1228 + encoding = self.GetEncoding()
  1229 + try:
  1230 + # Returns a unicode decoded in the own dicom encoding
  1231 + return name.decode(encoding, 'replace')
  1232 + except(UnicodeEncodeError):
  1233 + return name
  1234 +
1228 return "" 1235 return ""
1229 1236
1230 def GetPatientAge(self): 1237 def GetPatientAge(self):