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