def getpreferredencoding(do_setlocale = True): """Return the charset that the user is likely using.""" import _locale return _locale._getdefaultlocale()[1]