test-charmap.py 535 B

123456789101112131415161718192021222324252627282930
  1. from __future__ import print_function
  2. import sys
  3. import locale
  4. try:
  5. reload(sys)
  6. except NameError: # Python 3
  7. pass
  8. def main():
  9. encoding = locale.getdefaultlocale()[1]
  10. if not encoding:
  11. return False
  12. try:
  13. sys.setdefaultencoding(encoding)
  14. except AttributeError: # Python 3
  15. pass
  16. textmap = {
  17. 'cp936': u'\u4e2d\u6587',
  18. 'cp1252': u'Lat\u012Bna',
  19. 'cp932': u'\u306b\u307b\u3093\u3054'
  20. }
  21. if encoding in textmap:
  22. print(textmap[encoding])
  23. return True
  24. if __name__ == '__main__':
  25. print(main())