On this page
codecs.getencoder
Prev: codecs.getdecoder | Up: codecs | Next: codecs.getincrementaldecoder
Rel: codecs.backslashreplace_errors, codecs.Codec, codecs.CodecInfo, codecs.decode
Ref: docs.python.org — codecs.getencoder
Tags: #public #python3 #stdlib #codecs
Import
import codecs
from codecs import getencoder
Signature & Overview
codecs.getencoder(encoding)
Lookup up the codec for the given encoding and return its encoder function.
Usage
import codecs
enc = codecs.getencoder("utf-8")
raw, consumed = enc("abc")
assert (raw, consumed) == (b"abc", 3)
Gotchas
- Returns
(encoded_bytes, chars_consumed)tuple.
REPL Inspect
from codecs import getencoder
help(getencoder)
Linked from
Related notes
- tuts/python3/stdlib_module/codecs/getdecoder Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getincrementaldecoder Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/codecs/backslashreplace_errors Linked here; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/Codec Linked here; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/CodecInfo Linked here; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/decode Linked here; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/encode shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/EncodedFile shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getincrementalencoder shared tags: #codecs, #stdlib