pydicom.charset.encode_string¶
-
pydicom.charset.encode_string(value, encodings)[source]¶ Encode a unicode string value into
bytesusing encodings.New in version 1.2.
- Parameters
- Returns
The encoded string. If value could not be encoded with any of the given encodings, and
enforce_valid_valuesisFalse, a warning is issued, and value is encoded using the first encoding with replacement characters, resulting in data loss. Should bebytesfor Python 3 andstrfor Python 2.- Return type
- Raises
UnicodeEncodeError – If
enforce_valid_valuesisTrueand value could not be encoded with the supplied encodings.