2

I want to make windows application that convert text encoding of Txt file. so I need to get all text encoding supported by windows. I look for Encoding.GetEncodings() Method but it is not exist in Universal Windows Apps. so I try to get encoding by CodePage, and this is my code:

        List<string> list = new List<string>();
        List<string> errors = new List<string>();
        int[] code_page = { 0, 1200, 1201, 1252, 10003, 10008, 12000, 12001, 20127, 20936, 20949, 28591, 28598, 38598, 50220, 50221,
        50222, 50225, 50227, 51932, 51936, 51949, 52936, 57002, 57003, 57004, 57005, 57006, 57007, 57008, 57009, 57010, 57011, 65000, 65001 };
        for (int i = 0; i < code_page.Length; i++)
        {
            try
            {
                list.Add(Encoding.GetEncoding(code_page[i]).EncodingName);
            }
            catch (Exception ex) { errors.Add(code_page[i] + "\t\t" + ex.Message); }
        }
        }

And I have this result:

First list (Encoding)

  • Unicode (UTF-8)
  • Unicode
  • Unicode (Big-Endian)
  • Unicode (UTF-32)
  • Unicode (UTF-32 Big-Endian)
  • US-ASCII
  • Western European (ISO)
  • Unicode (UTF-7)
  • Unicode (UTF-8)

Errors list

  • 37___No data is available for encoding 37. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
  • 437__No data is available for encoding 437. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
  • 500__No data is available for encoding 500. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
  • ...etc

and my question is there any way to get all windows text encoding.

Thank you.

Community
  • 1
  • 1
Mohammad Diab
  • 25
  • 1
  • 5

0 Answers0