From c733b2405355831a695dd5ee8ea908dd05b68e43 Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Wed, 2 Apr 2014 14:25:35 -0300 Subject: [PATCH] FIX: Fixed problem with unicode in DICOM gender field --- invesalius/reader/dicom.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/invesalius/reader/dicom.py b/invesalius/reader/dicom.py index d3cc0e6..84be16d 100644 --- a/invesalius/reader/dicom.py +++ b/invesalius/reader/dicom.py @@ -1224,7 +1224,14 @@ class Parser(): return "" if (data): - return str(data) + name = data.strip() + encoding = self.GetEncoding() + try: + # Returns a unicode decoded in the own dicom encoding + return name.decode(encoding, 'replace') + except(UnicodeEncodeError): + return name + return "" def GetPatientAge(self): -- libgit2 0.21.2