3 ms·
> I really miss a "just give me an ascii version and ignore any errors, because I really don't care in this case" option... You can use options to either ignor
by conesus 16y ago
> I really miss a "just give me an ascii version and ignore any errors, because I really don't care in this case" option...
You can use options to either ignore or replace invalid characters.
>>> unicode('\x80abc', errors='strict')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0:
ordinal not in range(128)
>>> unicode('\x80abc', errors='replace')
u'\ufffdabc'
>>> unicode('\x80abc', errors='ignore')
u'abc'