Kirill,
Assuming that the Encoding class has static properties for all of the
avalilable encodings (e.g. Encoding.ASCII, Encoding.UTF8 etc) then the
following reflection code should do the trick:
using System.Reflection;
//...
foreach(PropertyInfo p in typeof(Encoding).GetProperties()) {
if (p.PropertyType == typeof(Encoding)) {
Encoding e = (Encoding)p.GetValue(null,null);
Console.WriteLine("{0},{1},{2}", e.CodePage,
e.EncodingName, e.BodyName);
}
}
Hope that helps!,
Duncan Smart
On Tue, 23 Apr 2002 20:30:09 -0700, Kirill 'Big K' Katsnelson
<[EMAIL PROTECTED]> wrote:
>System.Text.Encoding.GetEncoding () returns an encoding given its name
>or code page. Is there a way to enumerate available encodings, to display
>them in the UI?
>
>This works, but way too slow :)
>
>for (int i = -100; i < 65535; i++)
>{
> try
> {
> System.Text.Encoding e = System.Text.Encoding.GetEncoding (i);
> Console.WriteLine ("{0},{1},{2}", e.CodePage, e.EncodingName,
>e.BodyName);
> }
> catch (SystemException x)
> {
> }
>}
>
> -kkm
>
>You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.