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