Skip to content

Instantly share code, notes, and snippets.

@damnit
Last active August 29, 2015 14:05
Show Gist options
  • Save damnit/5f514d18836db7898e5b to your computer and use it in GitHub Desktop.
Save damnit/5f514d18836db7898e5b to your computer and use it in GitHub Desktop.
this module gives a shit about encoding
# -*- coding: utf-8 -*-
""" This module gives a shit about encoding. """
from __future__ import print_function
import sys
if __name__ == '__main__':
print('---------------------------')
print('| Unicode Analysis Script |')
print('---------------------------')
print('system default encoding : %s' % sys.getdefaultencoding())
print('standard output encoding : %s' % sys.stdout.encoding)
print('filesystem encoding : %s' % sys.getfilesystemencoding())
print('')
unikot = u'äµ'.encode('utf-8')
print('native unicode string : \'%s\'' % unikot)
ascii = u'äµ'.encode('ascii',errors='replace')
print('translated to ascii : \'%s\'' % ascii)
at_euro = u'äµ'.encode('iso-8859-15')
print('translated to iso-8859-15: \'%s\'' % at_euro)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment