pydicom.charset.convert_encodings¶
- pydicom.charset.convert_encodings(encodings)¶
Convert DICOM encodings into corresponding Python encodings.
Handles some common spelling mistakes and issues a warning in this case.
Handles stand-alone encodings: if they are the first encodings, additional encodings are ignored, if they are not the first encoding, they are ignored. In both cases, a warning is issued.
Invalid encodings are replaced with the default encoding with a respective warning issued, if
enforce_valid_values
isFalse
, otherwise an exception is raised.- Parameters
encodings (list of str) – The list of encodings as read from (0008,0005) Specific Character Set.
- Returns
A
list
of Python encodings corresponding to the DICOM encodings. If an encoding is already a Python encoding, it is returned unchanged. Encodings with common spelling errors are replaced by the correct encoding, and invalid encodings are replaced with the default encoding ifenforce_valid_values
isFalse
.- Return type
list of str
- Raises
LookupError – If encodings contains a value that could not be converted and
enforce_valid_values
isTrue
.