From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:42:08 +0000 (+0100) Subject: gh-48181: Document `codecs.charmap_build` (#135997) X-Git-Tag: v3.15.0a1~1134 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2bdd50309f543f449d7d82b64ed6f60ae0aa80b9;p=thirdparty%2FPython%2Fcpython.git gh-48181: Document `codecs.charmap_build` (#135997) --- diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 86511602fa5a..b231fa568cf3 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -53,6 +53,14 @@ any codec: :exc:`UnicodeDecodeError`). Refer to :ref:`codec-base-classes` for more information on codec error handling. +.. function:: charmap_build(string) + + Return a mapping suitable for encoding with a custom single-byte encoding. + Given a :class:`str` *string* of up to 256 characters representing a + decoding table, returns either a compact internal mapping object + ``EncodingMap`` or a :class:`dictionary ` mapping character ordinals + to byte values. Raises a :exc:`TypeError` on invalid input. + The full details for each codec can also be looked up directly: .. function:: lookup(encoding, /)