Make UTF environment detection more robust.

Fixes #125
This commit is contained in:
Aldo Cortesi 2013-06-09 11:20:02 +12:00
parent 7ef68b5a13
commit 9f6657727b
1 changed files with 4 additions and 2 deletions

View File

@ -62,12 +62,14 @@ if __name__ == '__main__':
opts.debug = options.debug
opts.palette = options.palette
if "utf" not in os.environ.get("LANG", "").lower():
spec = ""
for i in ["LANG", "LC_CTYPE", "LC_ALL"]:
spec += os.environ.get(i, "").lower()
if "utf" not in spec:
print >> sys.stderr, "Error: mitmproxy requires a UTF console environment."
print >> sys.stderr, "Set your LANG enviroment variable to something like en_US.UTF-8"
sys.exit(1)
m = console.ConsoleMaster(server, opts)
try:
m.run()