From 44cbfdc1e8e9c6c7fb115c7ea101e2532d58e436 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 8 Apr 2011 14:21:45 -0400 Subject: Fix command-line encoding processing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit String command-line options are converted to unicode using the input encoding. We use the fact that Python sets up the original sys.stdout to determine the terminal encoding. This should fix Anders Sneckenborg's issues with Swedish characters: C:\temp\slask4>be new "Svenska tecken åäö" Created bug with ID 6be/5c3 C:\temp\slask4> C:\temp\slask4> C:\temp\slask4>be list ERROR: 'ascii' codec can't decode byte 0xe5 in position 15: ordinal not in range(128) You should set a locale that supports unicode, e.g. export LANG=en_US.utf8 See http://docs.python.org/library/locale.html for details --- libbe/util/encoding.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libbe/util') diff --git a/libbe/util/encoding.py b/libbe/util/encoding.py index 5950bb9..c759529 100644 --- a/libbe/util/encoding.py +++ b/libbe/util/encoding.py @@ -49,11 +49,14 @@ def get_input_encoding(): return get_encoding() def get_output_encoding(): - return get_encoding() + return sys.__stdout__.encoding def get_filesystem_encoding(): return get_encoding() +def get_argv_encoding(): + return get_encoding() + def known_encoding(encoding): """ >>> known_encoding("highly-unlikely-encoding") -- cgit