Add UTF8NoBOM property to System.Text.Encoding class
#2312
Closed
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 adds a new property to the
System.Text.Encodingclass calledUTF8NoBOMwith an instance of theUTF8Encodingclass configured to not include the byte order mark (BOM).I opted to use the name
UTF8NoBOMbecause it's the name used in the internalEncodingCacheclass that is referenced in several places throughout the codebase.For consistency with other properties of the
Encodingclass such asUTF8for example, The argumentthrowOnInvalidBytesis not set on the constructor and it will use the default (false). This means we wouldn't be able to replace references toEncodingCache.UTF8NoBOMwith references toEncoding.UTF8NoBOMas they have different behavior.Resolves #2136 if we want to stop here for now, unless we want to also add other similar properties together such as
UnicodeNoBOMandUTF32NoBOM, etc. as suggested in #2136.