Conversation
…ehavior differences Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Clarify the Encoding.GetEncoding(0) and Encoding.Default behavior
Clarify Encoding.GetEncoding(0) and Encoding.Default behavior differences between .NET Framework and .NET Core+
Aug 19, 2025
gewarren
approved these changes
Aug 19, 2025
Contributor
gewarren
left a comment
There was a problem hiding this comment.
I left some suggestions for consideration.
12 tasks
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR clarifies the documentation for
Encoding.GetEncoding(0)andEncoding.Defaultto explain their different behaviors between .NET Framework and .NET Core/later versions.Background
In .NET Framework, both
Encoding.DefaultandEncoding.GetEncoding(0)return the system's active code page encoding. However, in .NET Core and later versions, this behavior changed:Encoding.Defaultalways returns UTF-8Encoding.GetEncoding(0)behavior depends on registered encoding providersThis difference can cause confusion for developers migrating code between frameworks.
Changes Made
Enhanced
Encoding.DefaultDocumentationAdded comprehensive remarks explaining that:
GetEncoding(0))Clarified
Encoding.GetEncoding(int)Behavior forcodepage = 0Updated documentation to explain platform and provider-specific behavior:
Encoding.Default)CodePagesEncodingProviderregistered: Windows returns active code page, non-Windows returns UTF-8Updated
Encoding.RegisterProviderDocumentationEnhanced explanation of how registering encoding providers affects
GetEncoding(0)behavior, with specific details aboutCodePagesEncodingProvider's platform-specific impact.Improved
CodePagesEncodingProviderDocumentationGetEncoding(int)method documentation with specificcodepage = 0behaviorThese changes help developers understand the encoding behavior differences and make informed decisions when writing cross-platform code.
Fixes #11711.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.