Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ print 'Santã claus is a biker'.decode('ascii') # Here I made expressely an error with a letter (ã)
- # that can be decoded in UTF-8 but not ASCII (this base 50's character encoding we discussed earlier)
- $ Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeDecodeError: 'ascii' codec can't decode
- byte 0xC3 0xA3 in position 1: ordinal not in range(128) # Note that ã is composed of two bytes :
- # `a` with code point `U+0061`, hexadecimal value `0xC3` and the tilde` ◌̃` with code point `U+0303` and hex decimal value `0xA3`
- # (Both of these code points belongs to UTF-8 as it was originally coded)
- $
- $ print 'Santa claus is a biker'.decode('ascii', errors='ignore')
- $ Sant claus is a biker
- $ print 'Santa claus is a biker'.decode('ascii', errors='replace')
- $ S��nt�� cl��us is a biker
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement