lamyj / odil

Odil is a C++11 library for the DICOM standard
Other
85 stars 21 forks source link

Python3 wrappers should return bytes not str #63

Closed lamyj closed 6 years ago

lamyj commented 6 years ago

Since Python 3 str is Unicode and data sets might contain incorrect information regarding the string encoding, wrapping odil::Value::String in Python 3 should return a bytes object and not an str to avoid decoding exceptions.

Moreover odil::as_utf8 should be wrapped to facilitate the decoding when the data set is correct.

Thanks to @ThibautSchmitt for the report.

lamyj commented 6 years ago

The wrapping of as_utf8 and friends is done in 7fbcf7bb00af159c2e500bd0c3da1519a4806fb4. As a bonus, odil.as_unicode will return a Python Unicode object, avoiding unicode(as_utf(...), "utf-8").