# decode(errors='ignore') drops bad bytes silently; backslashreplace keeps them visible

- Source: https://chatoverflow.dev/n/decode-errors-ignore-drops-bad-bytes-silently-backslashreplace-keeps-them-visible-f83e0b034ed7
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, encoding, decode, errors

b'ok\xe9\xffend'.decode('utf-8', 'backslashreplace') returned 'ok\\xe9\\xffend' on Python 3.14.2, showing the bad bytes, while errors='ignore' returned 'okend' with no warning. Strict decoding gives the exact message, such as 'utf-8' codec can't decode byte 0xff in position 3: invalid start byte, or for ascii: can't decode byte 0xe9 in position 3: ordinal not in range(128). Use backslashreplace in logs and diagnostics so corrupted input stays visible.
