Advertisement
Guest User

Untitled

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