-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Support for enumerating non-default code pages added with RegisterProvider (System.Text.Encoding) #25804
Comments
I would say that it is very surprising that after registering a new provider we can not get the full list of supported code pages. |
First we discussed this in PowerShell Core repo. Some cmdlets have |
Although I can see the issue, generally people interested in specific codepage encoding they already knew this codepage number and can just use it. another scenario would be getting the codepage name or number from some contents (like Xml, html, network stream,...etc.) and create encoding object. in such cases enumeration is not needed anyway. Could you tell exactly your scenario you want this? I understand power shell case but again this is not the scenario people use it. looking at the usage of System.Text.Encoding.GetEncodings, I am seeing it has very low usage. If you really in need for that, you can file an API proposal for adding GetEncodings method in the class EncodingProvider. and have the implementation support it. |
To elaborate on the scenario mentioned by @iSazonov: PowerShell Core users may want to discover available encodings and/or be assisted in selecting a specific encoding with tab completion: Get-Content file.txt -Encoding <tab> # should show all available encodings The above is currently limited to the .NET Core default encodings, even though PowerShell registers additional encodings on startup. |
@mklement0 I understand this and I am not objecting it. my point is this is not a real app scenario or real user scenario. in another word, my experience is not many people need to enumerate the code pages. Feel free to submit an API proposal as I mentioned in my previous reply. |
Thanks; I am glad you understand. It sounded like you wanted more details, based on this question of yours, in response to which I posted my elaboration.
As for deeming this not a real-world scenario:
Of course, it's impossible to see usage from the PowerShell side of things yet, given that the feature currently doesn't exist - for lack of API support (as well as the relative youth of PowerShell Core overall and, specifically, the I will submit an API proposal. |
Also we have a request to implement new cmdlet for converting encoding like iconv. iconv has |
Does the desktop version of power shell support if so, this would be a good thing to look at the usage of this functionality in power shell there. |
Unfortunately, Windows PowerShell (the In PowerShell Core's cross-platform world, encoding conversions strike me as more common, and presumably that's why that ability was added. @iSazonov's example of an |
Please see my API proposal at dotnet/corefx#28944. |
The documentation for
System.Text.Encoding.GetEncodings()
tells us (emphasis added):Is there no way to enumerate these additional encodings?
Unfortunately,
System.Text.CodePagesEncodingProvider.Instance
lacks a method for enumerating them.The text was updated successfully, but these errors were encountered: