aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/util/encoding.py
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spam@spamtrap.com>2012-02-20 15:34:59 +0000
committerW. Trevor King <wking@drexel.edu>2012-02-25 17:05:58 -0500
commit323da0a602bb689eecd6137dc3c676b3360a92b9 (patch)
treec26d146f8c1d666599d14da9c7e07dab85899cc5 /libbe/util/encoding.py
parentfa74991f0ea2d20fd8344242bf29ffc929880502 (diff)
downloadbugseverywhere-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 :(
Diffstat (limited to 'libbe/util/encoding.py')
-rw-r--r--libbe/util/encoding.py8
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():