pydicom.charset.convert_encodings

pydicom.charset.convert_encodings(encodings: None | str | MutableSequence[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 reading_validation_mode is WARN, or an exception is raised if it is set to RAISE.

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 reading_validation_mode is not set to RAISE.

Return type:

list of str

Raises:

LookupError – If encodings contains a value that could not be converted and reading_validation_mode is RAISE.