MCPcopy Index your code
hub / github.com/python/cpython / getpreferredencoding

Function getpreferredencoding

Lib/locale.py:639–648  ·  view source on GitHub ↗

Return the charset that the user is likely using.

(do_setlocale=True)

Source from the content-addressed store, hash-verified

637 CODESET
638except NameError:
639 def getpreferredencoding(do_setlocale=True):
640 """Return the charset that the user is likely using."""
641 if sys.flags.warn_default_encoding:
642 import warnings
643 warnings.warn(
644 "UTF-8 Mode affects locale.getpreferredencoding(). Consider locale.getencoding() instead.",
645 EncodingWarning, 2)
646 if sys.flags.utf8_mode:
647 return 'utf-8'
648 return getencoding()
649else:
650 # On Unix, if CODESET is available, use that.
651 def getpreferredencoding(do_setlocale=True):

Callers

nothing calls this directly

Calls 3

getencodingFunction · 0.85
setlocaleFunction · 0.85
warnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…