-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-128571: Document UTF-16/32 native byte order #139974
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
Conversation
Doc/library/codecs.rst
Outdated
| .. note:: | ||
|
|
||
| **Python UTF-16 and UTF-32 Codec Behavior** | ||
|
|
||
| Python's ``UTF-16`` and ``UTF-32`` codecs (when used without an explicit | ||
| byte order suffix like ``-BE`` or ``-LE``) follow the platform's native | ||
| byte order when no BOM is present. This differs from the Unicode Standard | ||
| specification, which states that UTF-16 and UTF-32 encoding schemes should | ||
| default to big-endian byte order when no BOM is present and no higher-level | ||
| protocol specifies the byte order. | ||
|
|
||
| This behavior was chosen for practical compatibility reasons, as it avoids | ||
| byte swapping on the most common platforms, but developers should be aware | ||
| of this difference when exchanging data with systems that strictly follow | ||
| the Unicode specification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently explained much more tersely on lines 993/994. I would suggest improving and slightly expanding the wording there, rather than duplicating content with this long note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @StanFromIreland
I pushed another commit. Please let me know if it is descriptive enough
…ssion in the issue
974f000 to
9a5ee89
Compare
|
Thank you, Looks good to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some little formalisation suggestions.
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
|
Please do not use the Update Branch button unless necessary (e.g. fixing conflicts, jogging the CI, or very old PRs) as it uses valuable resources. For more information see the devguide. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (I left a minor suggestion to deduplicate two sentences), Marc, please merge this when you have a chance.
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
|
Should we try a backport of this ? |
|
Sounds good to me, I think this paragraph is the same on all branches (and it's not like the specification has changed in the meantime :-), if there are conflicts I can fix. |
|
Thanks @Prhmma for the PR, and @malemburg for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Thanks @Prhmma for the PR, and @malemburg for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
Closes pythonGH-128571 (cherry picked from commit 920de7c) Co-authored-by: Parham MohammadAlizadeh <prhmma@gmail.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Closes pythonGH-128571 (cherry picked from commit 920de7c) Co-authored-by: Parham MohammadAlizadeh <prhmma@gmail.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
|
GH-140308 is a backport of this pull request to the 3.13 branch. |
|
GH-140309 is a backport of this pull request to the 3.14 branch. |
|
Thanks, both. |
Summary
Issue
📚 Documentation preview 📚: https://cpython-previews--139974.org.readthedocs.build/