Skip to content
Prev Previous commit
Next Next commit
Apply proposed changes.
  • Loading branch information
methane committed Apr 6, 2022
commit 1c60e5b6bfae00a47fd1eb63581a49aacb7a7953
5 changes: 3 additions & 2 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,9 @@ Glossary

Comment thread
methane marked this conversation as resolved.
On Windows, it is the ANSI code page (ex: ``cp1252``).
Comment thread
methane marked this conversation as resolved.
Outdated

``locale.getpreferredencoding(False)`` can be used to get the locale
encoding.
On Android and VxWorks, return ``"UTF-8"``.
Comment thread
methane marked this conversation as resolved.
Outdated

``locale.getencoding()`` can be used to get the locale encoding.
Comment thread
methane marked this conversation as resolved.

Python uses the :term:`filesystem encoding and error handler` to convert
between Unicode filenames and bytes filenames.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it would be helpful to mention here the Python UTF-8 Mode which ignores the locale encoding and always uses UTF-8. What do you think?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. This paragraph doesn't describe where the locale encoding is used.
This paragraph describes what the locale encoding is.
With this pull request, locale encoding is locale encoding even in UTF-8 mode.

On the other hand, following this paragraph looks unnecessary:

      Python uses the :term:`filesystem encoding and error handler` to convert
      between Unicode filenames and bytes filenames.

I will replace it with See also :term:`filesystem encoding and error handler`.

Expand Down
9 changes: 6 additions & 3 deletions Doc/library/locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,13 @@ The :mod:`locale` module defines the following exception and functions:

.. function:: getencoding()

Returns the :term:`locale encoding`.
Get the current :term:`locale encoding`:

On Android, it always returns ``"UTF-8"``, the :term:`locale encoding` is
ignored.
* On Android and VxWorks, return ``"UTF-8"``.
* On Unix, return the encoding of the current :data:`LC_CTYPE` locale.
Return ``"UTF-8"`` if :ref:`nl_langinfo(CODESET) <nl_langinfo>`
returns an empty string: for example, if the current LC_CTYPE locale is not supported.
* On Windows, return the ANSI code page.

This function is same to ``getpreferredencoding(False)`` except this
Comment thread
methane marked this conversation as resolved.
Outdated
function ignore the :ref:`UTF-8 Mode <utf8-mode>`.
Comment thread
methane marked this conversation as resolved.
Outdated
Expand Down