@@ -1476,6 +1476,52 @@ mapping. It is not supported by :meth:`str.encode` (which only produces
14761476 Restoration of the ``rot13 `` alias.
14771477
14781478
1479+ :mod: `encodings ` --- Encodings package
1480+ --------------------------------------
1481+
1482+ .. module :: encodings
1483+ :synopsis: Encodings package
1484+
1485+ This module implements the following functions:
1486+
1487+ .. note ::
1488+ These functions should not be used directly, except for testing purposes.
1489+
1490+ .. function :: normalize_encoding(encoding)
1491+
1492+ Normalize encoding name *encoding *.
1493+
1494+ Normalization works as follows: all non-alphanumeric characters except the
1495+ dot used for Python package names are collapsed and replaced with a single
1496+ underscore, leading and trailing underscores are removed.
1497+ For example, ``' -;#' `` becomes ``'_' ``.
1498+
1499+ Note that *encoding * should be ASCII only.
1500+
1501+
1502+ .. function :: search_function(encoding)
1503+
1504+ Search for the codec module corresponding to the given encoding name
1505+ *encoding *.
1506+
1507+ This function first normalizes the *encoding * using
1508+ :func: `normalize_encoding `, then looks for a corresponding alias.
1509+ It attempts to import a codec module from the encodings package using either
1510+ the alias or the normalized name. If the module is found and defines a valid
1511+ ``getregentry() `` function that returns a :class: `codecs.CodecInfo ` object,
1512+ the codec is cached and returned.
1513+
1514+ If the codec module defines a ``getaliases() `` function any returned aliases
1515+ are registered for future use.
1516+
1517+
1518+ This module implements the following exception:
1519+
1520+ .. exception :: CodecRegistryError
1521+
1522+ Raised when a codec is invalid or incompatible.
1523+
1524+
14791525:mod: `encodings.idna ` --- Internationalized Domain Names in Applications
14801526------------------------------------------------------------------------
14811527
0 commit comments