@@ -30,7 +30,7 @@ UTF-8 becomes de-facto standard text encoding.
3030 default.
3131* Most websites and text data on the internet uses UTF-8.
3232* And many other popular programming languages including node.js, Go, Rust,
33- Ruby, and Java uses UTF-8 by default.
33+ and Java uses UTF-8 by default.
3434
3535Changing the default encoding to UTF-8 makes Python easier to interoperate
3636with them.
@@ -44,34 +44,25 @@ source files). Inconsistent default encoding caused many bugs.
4444Specification
4545=============
4646
47- Changes to UTF-8 mode
48- ---------------------
49-
50- Currently, UTF-8 mode affects to ``locale.getpreferredencoding() ``.
51-
52- This PEP proposes to remove this override. UTF-8 mode will not affect to
53- ``locale `` module.
54-
55- After this change, UTF-8 mode affects to:
56-
57- * stdin, stdout, stderr
58-
59- * User can override it with ``PYTHONIOENCODING ``.
47+ Enable UTF-8 mode by default
48+ ----------------------------
6049
61- * filesystem encoding
50+ Python enables UTF-8 mode by default.
6251
63- * ``TextIOWrapper `` and APIs using it including ``open() ``,
64- ``Path.read_text() ``, ``subprocess.Popen(cmd, text=True) ``, etc...
52+ User can still disable UTF-8 mode by setting ``PYTHONUTF8=0 `` or ``-X utf8=0 ``.
6553
66- This change will be introduced in Python 3.11 if possible.
6754
55+ ``locale.get_encoding() ``
56+ -------------------------
6857
69- Enable UTF-8 mode by default
70- ----------------------------
58+ Add `` locale.get_encoding() ``. It is same to
59+ `` locale.getpreferredencoding(False) `` except it don't follow UTF-8 mode.
7160
72- Python enables UTF-8 mode by default.
61+ This API will be used by ``io.TextIOWrapper `` to support ``encoding="locale" ``
62+ option.
7363
74- User can still disable UTF-8 mode by setting ``PYTHONUTF8=0 `` or ``-X utf8=0 ``.
64+ This change will be released in Python 3.11 so that users can prepare before
65+ UTF-8 mode is enabled by default.
7566
7667
7768Backward Compatibility
@@ -86,10 +77,14 @@ should be announced very loudly.
8677
8778To resolve this backward incompatibility, users can do:
8879
89- * Disable UTF-8 mode
80+ * Disable UTF-8 mode.
9081* Use ``EncodingWarning `` to find where the default encoding is used and use
91- ``encoding="locale" `` option to keep using locale encoding
82+ ``encoding="locale" `` option if locale encoding should be used
9283 (as defined in :pep: `597 `).
84+ * Find every occurrence of ``locale.getpreferredencoding(False) `` in the
85+ application, and replace it with ``locale.get_locale_encoding() `` if
86+ locale encoding should be used.
87+ * Test the application with UTF-8 mode.
9388
9489
9590Preceding examples
@@ -125,11 +120,10 @@ How to teach this
125120=================
126121
127122For new users, this change reduces things that need to teach.
123+ Users don't need to learn about text encoding in their first year.
124+ They need to learn it when they need to use non-UTF-8 text files.
128125
129- Users can delay learning about text encoding until they need to handle
130- non-UTF-8 text files.
131-
132- For existing users, see `Backward compatibility `_ section.
126+ For existing users, see the `Backward compatibility `_ section.
133127
134128
135129References
0 commit comments