pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/cee5da861091cdaca99f0636af7ab8c4b0274e5f

stylesheet" href="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> bpo-39287: Doc: Add UTF-8 mode section in using/windows. (GH-17935) · python/cpython@cee5da8 · GitHub
Skip to content

Commit cee5da8

Browse files
bpo-39287: Doc: Add UTF-8 mode section in using/windows. (GH-17935)
Co-Authored-By: Kyle Stanley <aeros167@gmail.com> (cherry picked from commit 148610d) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
1 parent 46735c7 commit cee5da8

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

Doc/using/cmdline.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,6 @@ conflict.
936936

937937
Also available as the :option:`-X` ``utf8`` option.
938938

939-
.. availability:: \*nix.
940-
941939
.. versionadded:: 3.7
942940
See :pep:`540` for more details.
943941

Doc/using/windows.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,50 @@ existed)::
602602

603603
C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Python 3.8
604604

605+
.. _win-utf8-mode:
606+
607+
UTF-8 mode
608+
==========
609+
610+
.. versionadded:: 3.7
611+
612+
Windows still uses legacy encodings for the system encoding (the ANSI Code
613+
Page). Python uses it for the default encoding of text files (e.g.
614+
:func:`locale.getpreferredencoding`).
615+
616+
This may cause issues because UTF-8 is widely used on the internet
617+
and most Unix systems, including WSL (Windows Subsystem for Linux).
618+
619+
You can use UTF-8 mode to change the default text encoding to UTF-8.
620+
You can enable UTF-8 mode via the ``-X utf8`` command line option, or
621+
the ``PYTHONUTF8=1`` environment variable. See :envvar:`PYTHONUTF8` for
622+
enabling UTF-8 mode, and :ref:`setting-envvars` for how to modify
623+
environment variables.
624+
625+
When UTF-8 mode is enabled:
626+
627+
* :func:`locale.getpreferredencoding` returns ``'UTF-8'`` instead of
628+
the system encoding. This function is used for the default text
629+
encoding in many places, including :func:`open`, :class:`Popen`,
630+
:meth:`Path.read_text`, etc.
631+
* :data:`sys.stdin`, :data:`sys.stdout`, and :data:`sys.stderr`
632+
all use UTF-8 as their text encoding.
633+
* You can still use the system encoding via the "mbcs" codec.
634+
635+
Note that adding ``PYTHONUTF8=1`` to the default environment variables
636+
will affect all Python 3.7+ applications on your system.
637+
If you have any Python 3.7+ applications which rely on the legacy
638+
system encoding, it is recommended to set the environment variable
639+
temporarily or use the ``-X utf8`` command line option.
640+
641+
.. note::
642+
Even when UTF-8 mode is disabled, Python uses UTF-8 by default
643+
on Windows for:
644+
645+
* Console I/O including standard I/O (see :pep:`528` for details).
646+
* The filesystem encoding (see :pep:`529` for details).
647+
648+
605649
.. _launcher:
606650

607651
Python Launcher for Windows

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy