Skip to content

Instantly share code, notes, and snippets.

@mashiro
Created April 13, 2010 08:08
Show Gist options
  • Select an option

  • Save mashiro/364414 to your computer and use it in GitHub Desktop.

Select an option

Save mashiro/364414 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import codecs
encoding = sys.getfilesystemencoding()
sys.stdin = codecs.getreader(encoding)(sys.stdin)
sys.stdout = codecs.getwriter(encoding)(sys.stdout)
print 'encoding: %s' % encoding
str = sys.stdin.readline()
print type(str) # unicode
print str
str = u'はうはう'
print type(str) # unicode
print str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment