[issue38056] Add examples for common text encoding Error Handlers
New submission from Ma Lin <malincns@163.com>: Text descriptions about `Error Handlers` are not very friendly to novices. https://docs.python.org/3/library/codecs.html#error-handlers For example: 'xmlcharrefreplace' Replace with the appropriate XML character reference (only for encoding). Implemented in :func:`xmlcharrefreplace_errors`. 'backslashreplace' Replace with backslashed escape sequences. Implemented in :func:`backslashreplace_errors`. 'namereplace' Replace with ``\N{...}`` escape sequences (only for encoding). Implemented in :func:`namereplace_errors`. Novices may not know what these are. Giving some examples may help the reader to understand more intuitively. The effect picture is attached. I picked two characters: ß https://www.compart.com/en/unicode/U+00DF ♬ https://www.compart.com/en/unicode/U+266C ---------- assignee: docs@python components: Documentation files: effect.png messages: 351329 nosy: Ma Lin, docs@python priority: normal severity: normal status: open title: Add examples for common text encoding Error Handlers versions: Python 3.7, Python 3.8, Python 3.9 Added file: https://bugs.python.org/file48599/effect.png _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38056> _______________________________________
Change by Ma Lin <malincns@163.com>: ---------- keywords: +patch pull_requests: +15386 stage: -> patch review pull_request: https://github.com/python/cpython/pull/15732 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38056> _______________________________________
Ma Lin <malincns@163.com> added the comment: PR 15732 became an overhaul: - replace/backslashreplace/surrogateescape were wrongly described as encoding only, in fact they can also be used in decoding. - clarify the description of surrogatepass. - add more descriptions to each handler. - add two REPL examples. - add indexes for Error Handler's name. - add default parameter values in codecs.rst - improve term "text encoding". PR 15732 has a screenshot of the Error Handlers section. ---------- components: +Unicode nosy: +ezio.melotti, vstinner title: Add examples for common text encoding Error Handlers -> Overhaul Error Handlers section in codecs documentation _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38056> _______________________________________
participants (1)
-
Ma Lin