This is a development version (9.14.0.dev) and may be unstable. Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.14.0.dev / IPython / utils / encoding / getdefaultencoding

function

IPython.utils.encoding:getdefaultencoding

source: /IPython/utils/encoding.py :46

Signature

def   getdefaultencoding ( prefer_stream : object | bool = <object object at 0x0000> )  →  str

Summary

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