Last active
August 29, 2015 14:05
-
-
Save damnit/5f514d18836db7898e5b to your computer and use it in GitHub Desktop.
this module gives a shit about encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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