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 or str) – The encoded byte string in the DICOM element value. Should be
bytes
for Python 3 andstr
for Python 2. - 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 (Python 3) or characters (Python 2)) – 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
isFalse
, a warning is issued, and value is decoded using the first encoding with replacement characters, resulting in data loss. Returnsstr
for Python 3 andunicode
for Python 2.Return type: str or unicode
Raises: UnicodeDecodeError
– Ifenforce_valid_values
isTrue
and value could not be decoded with the given encodings.- value (bytes or str) – The encoded byte string in the DICOM element value. Should be