Advertisement
Guest User

Untitled

a guest
Aug 15th, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import quopri
  3. import StringIO
  4.  
  5. # helpers (the quopri module only supports file-to-file conversion)
  6.  
  7. def encodestring(instring, tabs=0):
  8. outfile = StringIO.StringIO()
  9. quopri.encode(StringIO.StringIO(instring), outfile, tabs)
  10. return outfile.getvalue()
  11.  
  12. def decodestring(instring):
  13. outfile = StringIO.StringIO()
  14. quopri.decode(StringIO.StringIO(instring), outfile)
  15. return outfile.getvalue()
  16.  
  17. firstExample = "=91hey=92"
  18. print decodestring(firstExample).decode('windows-1252')
  19.  
  20. secondExample = "=E2=80=98=E2=80=99,=E2=80=9C=E2=80=9D=3Dhey=C3=B7=C2=BD=C3=96=C3=B1=E2=99=A6=E2=86=92%@=C2=A5=C3=B7"
  21. print decodestring(secondExample).decode('utf-8')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement