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.Encoding
class calledUTF8NoBOM
with an instance of theUTF8Encoding
class configured to not include the byte order mark (BOM).I opted to use the name
UTF8NoBOM
because it's the name used in the internalEncodingCache
class that is referenced in several places throughout the codebase.For consistency with other properties of the
Encoding
class such asUTF8
for example, The argumentthrowOnInvalidBytes
is not set on the constructor and it will use the default (false
). This means we wouldn't be able to replace references toEncodingCache.UTF8NoBOM
with references toEncoding.UTF8NoBOM
as 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
UnicodeNoBOM
andUTF32NoBOM
, etc. as suggested in #2136.