-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
bpo-47000: Add locale.getencoding()
#32068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
cd4bccc
aaa8956
104206a
8b50eb1
a0204c2
08413f1
f61b622
1c60e5b
7397493
44730dd
7720b10
104008d
a8e50bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -710,8 +710,9 @@ Glossary | |
|
|
||
| On Windows, it is the ANSI code page (ex: ``cp1252``). | ||
|
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"``. | ||
|
methane marked this conversation as resolved.
Outdated
|
||
|
|
||
| ``locale.getencoding()`` can be used to get the locale encoding. | ||
|
methane marked this conversation as resolved.
|
||
|
|
||
| Python uses the :term:`filesystem encoding and error handler` to convert | ||
| between Unicode filenames and bytes filenames. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. On the other hand, following this paragraph looks unnecessary: I will replace it with |
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -334,10 +334,26 @@ The :mod:`locale` module defines the following exception and functions: | |||||
| locale. See also the :term:`filesystem encoding and error handler`. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest to copy/paste this paragraph to getencoding() doc. |
||||||
|
|
||||||
| .. versionchanged:: 3.7 | ||||||
| The function now always returns ``UTF-8`` on Android or if the | ||||||
| The function now always returns ``"UTF-8"`` on Android or if the | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| :ref:`Python UTF-8 Mode <utf8-mode>` is enabled. | ||||||
|
|
||||||
|
|
||||||
| .. function:: getencoding() | ||||||
|
|
||||||
| Get the current :term:`locale encoding`: | ||||||
|
|
||||||
| * On Android and VxWorks, return ``"UTF-8"``. | ||||||
| * On Unix, return the encoding of the current :data:`LC_CTYPE` locale. | ||||||
| Return ``"UTF-8"`` if ``nl_langinfo(CODESET)`` 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 | ||||||
|
methane marked this conversation as resolved.
Outdated
|
||||||
| function ignore the :ref:`UTF-8 Mode <utf8-mode>`. | ||||||
|
methane marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| .. versionadded:: 3.11 | ||||||
|
|
||||||
|
|
||||||
| .. function:: normalize(localename) | ||||||
|
|
||||||
| Returns a normalized locale code for the given locale name. The returned locale | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -274,6 +274,12 @@ inspect | |||||
| * Add :func:`inspect.ismethodwrapper` for checking if the type of an object is a | ||||||
| :class:`~types.MethodWrapperType`. (Contributed by Hakan Çelik in :issue:`29418`.) | ||||||
|
|
||||||
| locale | ||||||
| ------ | ||||||
|
|
||||||
| * Add :func:`locale.getencoding` that is same to | ||||||
|
methane marked this conversation as resolved.
Outdated
|
||||||
| ``locale.getpreferredencoding(False)`` but ignores :ref:`UTF-8 Mode <utf8-mode>`. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like repeating "Python" to remind that it's unrelated to the Unix locale, but really something specific to Python which ignores the locale.
Suggested change
|
||||||
|
|
||||||
| math | ||||||
| ---- | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add :func:`locale.getencoding`. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can copy/paste the Doc/whatsnew/3.11.rst entry entry. |
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.