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