bundles / IPython 9.17.0 / IPython / utils / encoding / getdefaultencoding
function
IPython.utils.encoding:getdefaultencoding
Signature
def getdefaultencoding(prefer_stream: object | bool = <object object at 0x0000>) → strSummary
Return IPython's guess for the default encoding for bytes as text.
Extended Summary
If prefer_stream is True (default), asks for stdin.encoding first, to match the calling Terminal, but that is often None for subprocesses.
Then fall back on locale.getpreferredencoding(), which should be a sensible platform default (that respects LANG environment), and finally to sys.getdefaultencoding() which is the most conservative option, and usually UTF8 as of Python 3.
Aliases
IPython.utils.encoding.getdefaultencoding