-
Notifications
You must be signed in to change notification settings - Fork 5k
API proposal: expose System.Text.Encoding.Latin1 getter publicly #31549
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
Comments
We already have it and called Encoding.Latin1
|
I think @GrabYourPitchforks is proposing it be made public. |
Ah, somehow I had the impression that Encoding.Latin1 is already public :-) so it make sense to expose it (maybe with different name). |
I'd be fine with keeping the property name |
I agree we don't have to expose Latin1Encoding class. For the naming, we need to choose the name which people more familiar with:
if we can have the name indicate |
I think this API would be fine. Outside of the web (iirc HTML5 actually considers the two identical), Windows-1252 is in my experience even more common than ISO-8859-1. |
I updated the proposal to perform best-fit mapping during the narrowing conversion. This provides compatibility with the existing |
namespace System.Text
{
public partial class Encoding
{
public static Encoding Latin1 => Encoding.GetEncoding("iso-8859-1");
}
} |
The ISO-8859-1 encoding is used somewhat commonly in web scenarios since it's the encoding normally specified for headers. We should consider having a fast-access property for this encoding just like we have for
Encoding.UTF8
.The workaround for now is to use
Encoding.GetEncoding("iso-8859-1", ...)
, which works but is not convenient or optimized.API Proposal
The return value of this would be equivalent to calling
Encoding.GetEncoding("iso-8859-1")
. Thebyte
tochar
conversion is a naive widening operation. Thechar
tobyte
conversion is a naive narrowing operation, with anychar
values above0x007F
being best-fit mapped to an ASCII byte. If a best-fit mapping is unavailable then the character is converted to(byte)'?'
.If the developer wishes to change the fallback behavior or to enable best fit mapping, they can call
Encoding.GetEncoding("iso-8859-1", ...)
and pass custom fallback behaviors as needed for the newly-created instance.This proposal does not intend on making the existing internal
Latin1Encoding
class public./cc @davidfowl
The text was updated successfully, but these errors were encountered: