pydicom.charset.decode_string

pydicom.charset.decode_string(value, encodings, delimiters)

Decode an encoded byte value into a unicode string using encodings.

New in version 1.2.

Parameters
  • value (bytes) – The encoded byte string in the DICOM element value. Should be bytes

  • encodings (list of str) – The encodings needed to decode the string as a list of Python encodings, converted from the encodings in (0008,0005) Specific Character Set.

  • delimiters (set of int) – A set of characters or character codes, each of which resets the encoding in value.

Returns

The decoded unicode string. If the value could not be decoded, and enforce_valid_values is False, a warning is issued, and value is decoded using the first encoding with replacement characters, resulting in data loss.

Return type

str

Raises

UnicodeDecodeError – If enforce_valid_values is True and value could not be decoded with the given encodings.