1 # Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
3 # This file is part of Hooke.
5 # Hooke is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 # Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with Hooke. If not, see
17 # <http://www.gnu.org/licenses/>.
19 """Define useful encoding-extraction functions.
27 """Guess a useful input/output/filesystem encoding.
29 Maybe we need seperate encodings for input/output and filesystem?
32 encoding = locale.getpreferredencoding() or sys.getdefaultencoding()
33 if sys.platform != 'win32' or sys.version_info[:2] > (2, 3):
34 encoding = locale.getlocale(locale.LC_TIME)[1] or encoding
35 # Python 2.3 on windows doesn't know about 'XYZ' alias for 'cpXYZ'
38 def get_input_encoding():
39 "Guess the input encoding."
42 def get_output_encoding():
43 "Guess the output encoding."
46 def get_filesystem_encoding():
47 "Guess the filesystem encoding."