Encoding and decoding between Elixir strings (UTF-8 binaries) and raw byte sequences, for the encodings ftfy needs.
This stands in for Python's str.encode / bytes.decode together with the
custom codecs registered by ftfy.bad_codecs:
- single-byte charmap encodings (
latin-1,sloppy-windows-*,iso-8859-2,macroman,cp437, non-sloppywindows-1252) - the
utf-8-variantscodec (CESU-8 / Java modified UTF-8) - standard
utf-8
Functions return {:ok, result} / {:error, reason} rather than raising, so
callers can mirror Python's try/except UnicodeDecodeError with case.
Summary
Functions
The single-byte charmap encodings this module knows how to handle.
Decode a raw byte binary into a string, using encoding.
Encode a string into raw bytes, using encoding.
Functions
The single-byte charmap encodings this module knows how to handle.
Decode a raw byte binary into a string, using encoding.
Returns {:ok, string} or {:error, :invalid}.
Encode a string into raw bytes, using encoding.
Returns {:ok, bytes} or {:error, :unencodable}.