diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spam@spamtrap.com> | 2012-02-20 15:34:59 +0000 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2012-02-25 17:05:58 -0500 |
commit | 323da0a602bb689eecd6137dc3c676b3360a92b9 (patch) | |
tree | c26d146f8c1d666599d14da9c7e07dab85899cc5 | |
parent | fa74991f0ea2d20fd8344242bf29ffc929880502 (diff) | |
download | bugseverywhere-323da0a602bb689eecd6137dc3c676b3360a92b9.tar.gz |
Added BE_INPUT_ENCODING and BE_OUTPUT_ENCODING to allow charset for stdin and stdout to be overridden. This is necessary on Windows as there is no way for external programs to set stdin or stdout charsets :(
-rw-r--r-- | libbe/util/encoding.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libbe/util/encoding.py b/libbe/util/encoding.py index ee51993..a33678f 100644 --- a/libbe/util/encoding.py +++ b/libbe/util/encoding.py @@ -34,6 +34,10 @@ if libbe.TESTING == True: ENCODING = os.environ.get('BE_ENCODING', None) "override get_encoding() output" +INPUT_ENCODING = os.environ.get('BE_INPUT_ENCODING', None) +"override get_input_encoding() output" +OUTPUT_ENCODING = os.environ.get('BE_OUTPUT_ENCODING', None) +"override get_output_encoding() output" def get_encoding(): """ @@ -46,9 +50,13 @@ def get_encoding(): return encoding def get_input_encoding(): + if INPUT_ENCODING != None: + return INPUT_ENCODING return sys.__stdin__.encoding or get_encoding() def get_output_encoding(): + if OUTPUT_ENCODING != None: + return OUTPUT_ENCODING return sys.__stdout__.encoding or get_encoding() def get_text_file_encoding(): |