pynetdicom._config.CODECS

pynetdicom._config.CODECS: Tuple[str, ...] = ('ascii',)

Customise the codecs used to decode text values.

Added in version 2.0.

Warning

The DICOM Standard specifies ISO 646 (ASCII) as the only valid codec for encoded strings. The use of additional fallback codecs may result in unexpected behaviour in pynetdicom.

When string values are encoded by pynetdicom only ASCII is used.

The specified codecs will be used when decoding the following parameters:

  • A-ASSOCIATE-RQ: Called AE Title, Calling AE Title

    • Application Context Item: Application Context Name

    • Presentation Context Items

      • Abstract Syntax Sub-item: Abstract Syntax Name

      • Transfer Syntax Sub-item: Transfer Syntax Name

    • User Information Items

      • Implementation Class UID Sub-item: Implementation Class UID

      • Implementation Version Name Sub-item: Implementation Version Name

      • SCP/SCU Role Selection Sub-item: SOP Class UID

      • SOP Class Extended Negotiation Sub-item: SOP Class UID

      • SOP Class Common Extended Negotiation Sub-item: SOP Class UID, Service Class UID, Related General SOP Class UID

  • A-ASSOCIATE-AC

    • Application Context Item: Application Context Name

    • Presentation Context Item:

      • Transfer Syntax Sub-item: Transfer Syntax Name

    • User Information Items

      • Implementation Class UID Sub-item: Implementation Class UID

      • Implementation Version Name Sub-item: Implementation Version Name

      • SCP/SCU Role Selection Sub-item: SOP Class UID

      • SOP Class Extended Negotiation Sub-item: SOP Class UID

Possible codecs are given in the Python documentation here. Decoding will be attempted in the order that the codecs appear in CODECS and any fallback codecs should be added after "ascii".

If a fallback successfully decodes an encoded value the string will be converted to ASCII using str.encode() with the errors parameter set to "ignore".

Default: ("ascii",)

Examples

Add UTF-8 as a fallback codec:

>>> from pynetdicom import _config
>>> _config.CODECS = ("ascii", "utf-8")