Skip to content

Instantly share code, notes, and snippets.

@zed
Created July 1, 2013 04:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zed/5898423 to your computer and use it in GitHub Desktop.
Save zed/5898423 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import locale
import os
import sys
envname = "PYTHONIOENCODING"
print("{}:\t{}".format(envname, os.environ.get(envname)))
for set_locale in [False]:
print("locale({}):\t{}".format(set_locale,
locale.getpreferredencoding(set_locale)))
for streamname in "stdout stderr stdin".split():
stream = getattr(sys, streamname)
print("device({}):\t{}".format(streamname,
os.device_encoding(stream.fileno())))
print("{}.encoding:\t{}".format(streamname, stream.encoding))
for set_locale in [False, True]:
print("locale({}):\t{}".format(set_locale,
locale.getpreferredencoding(set_locale)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment