3 ms·
> As another data point, the node.js interpreter chooses to print the � replacement char instead of raising an exception. You can do the same in Python: >
by js2 3y ago
> As another data point, the node.js interpreter chooses to print the � replacement char instead of raising an exception.
You can do the same in Python:
>>> print(s.encode("utf-8","replace").decode("utf-8"))
?
Or do this:
import sys
sys.stdout.reconfigure(errors="replace")
Alternately, start python with:
PYTHONIOENCODING=utf8:replace
You can also use "ignore" to drop the illegal character entirely.