@@ -1498,6 +1498,66 @@ mapping. It is not supported by :meth:`str.encode` (which only produces
14981498 Restoration of the ``rot13 `` alias.
14991499
15001500
1501+ :mod: `encodings ` --- Encodings package
1502+ --------------------------------------
1503+
1504+ .. module :: encodings
1505+ :synopsis: Encodings package
1506+
1507+ This module implements the following functions:
1508+
1509+ .. function :: normalize_encoding(encoding)
1510+
1511+ Normalize encoding name *encoding *.
1512+
1513+ Normalization works as follows: all non-alphanumeric characters except the
1514+ dot used for Python package names are collapsed and replaced with a single
1515+ underscore, leading and trailing underscores are removed.
1516+ For example, ``' -;#' `` becomes ``'_' ``.
1517+
1518+ Note that *encoding * should be ASCII only.
1519+
1520+
1521+ .. note ::
1522+ The following functions should not be used directly, except for testing
1523+ purposes; :func: `codecs.lookup ` should be used instead.
1524+
1525+
1526+ .. function :: search_function(encoding)
1527+
1528+ Search for the codec module corresponding to the given encoding name
1529+ *encoding *.
1530+
1531+ This function first normalizes the *encoding * using
1532+ :func: `normalize_encoding `, then looks for a corresponding alias.
1533+ It attempts to import a codec module from the encodings package using either
1534+ the alias or the normalized name. If the module is found and defines a valid
1535+ ``getregentry() `` function that returns a :class: `codecs.CodecInfo ` object,
1536+ the codec is cached and returned.
1537+
1538+ If the codec module defines a ``getaliases() `` function any returned aliases
1539+ are registered for future use.
1540+
1541+
1542+ .. function :: win32_code_page_search_function(encoding)
1543+
1544+ Search for a Windows code page encoding *encoding * of the form ``cpXXXX ``.
1545+
1546+ If the code page is valid and supported, return a :class: `codecs.CodecInfo `
1547+ object for it.
1548+
1549+ .. availability :: Windows.
1550+
1551+ .. versionadded :: 3.14
1552+
1553+
1554+ This module implements the following exception:
1555+
1556+ .. exception :: CodecRegistryError
1557+
1558+ Raised when a codec is invalid or incompatible.
1559+
1560+
15011561:mod: `encodings.idna ` --- Internationalized Domain Names in Applications
15021562------------------------------------------------------------------------
15031563
0 commit comments