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 under the
6 # terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option) any
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with Hooke. If not, see <http://www.gnu.org/licenses/>.
18 """Define useful encoding-extraction functions.
26 """Guess a useful input/output/filesystem encoding.
28 Maybe we need seperate encodings for input/output and filesystem?
31 encoding = locale.getpreferredencoding() or sys.getdefaultencoding()
32 if sys.platform != 'win32' or sys.version_info[:2] > (2, 3):
33 encoding = locale.getlocale(locale.LC_TIME)[1] or encoding
34 # Python 2.3 on windows doesn't know about 'XYZ' alias for 'cpXYZ'
37 def get_input_encoding():
38 "Guess the input encoding."
41 def get_output_encoding():
42 "Guess the output encoding."
45 def get_filesystem_encoding():
46 "Guess the filesystem encoding."