pydicom.charset.convert_encodings

pydicom.charset.convert_encodings(encodings: Union[str, List[str]]) → List[str][source]

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 is False, otherwise an exception is raised.

Parameters

encodings (str or list of str) – The encoding or 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 if enforce_valid_values is False.

Return type

list of str

Raises

LookupError – If encodings contains a value that could not be converted and enforce_valid_values is True.