Skip to content

Instantly share code, notes, and snippets.

@aoeuidht
Created November 25, 2012 11:53
Show Gist options
  • Save aoeuidht/4143224 to your computer and use it in GitHub Desktop.
Save aoeuidht/4143224 to your computer and use it in GitHub Desktop.
xhrproxy should support gbk encoding
def decode(s, encodings=('gbk', 'utf8', 'windows-1251', 'iso-8859-1')):
for encoding in encodings:
try:
return s.decode(encoding)
except UnicodeDecodeError:
pass
return s.decode('iso-8859-1', 'ignore')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment