fork download
  1. using System;
  2. using System.Text;
  3.  
  4. public class Test {
  5. public static void Main() {
  6. Action<string, Func<Encoding>> act = delegate(string name, Func<Encoding> getEncoding) {
  7. string encInfo = null;
  8. try {
  9. Encoding encoding = getEncoding();
  10. encInfo = string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", new Object[]{
  11. encoding.GetType().Name,
  12. encoding.CodePage,
  13. encoding.WindowsCodePage,
  14. new Func<string>(delegate () {
  15. byte[] data = encoding.GetPreamble();
  16. StringBuilder sb = new StringBuilder();
  17. if(data == null) {
  18. sb.Append("(null)");
  19. } else {
  20. sb.Append(BitConverter.ToString(data).Replace("-", " "));
  21. sb.Append(" ");
  22. sb.Append(string.Format("({0})", new object[]{data.Length}));
  23. }
  24. return sb.ToString();
  25. })(),
  26. encoding.EncodingName,
  27. encoding.HeaderName,
  28. encoding.BodyName,
  29. encoding.WebName,
  30. });
  31. } catch(Exception e) {
  32. encInfo = e.Message;
  33. // encInfo = "*************************";
  34. }
  35. Console.WriteLine("{0} => {1}", new object[]{name, encInfo});
  36. };
  37. Action<int> acti = delegate(int cp) {
  38. act(string.Format("Encoding.GetEncoding({0})", new object[]{cp}), delegate() {
  39. return Encoding.GetEncoding(cp);
  40. });
  41. };
  42. Action<string> acts = delegate(string name) {
  43. act(string.Format("Encoding.GetEncoding(\"{0}\")", new object[]{name}), delegate() {
  44. return Encoding.GetEncoding(name);
  45. });
  46. };
  47. Action<string, Encoding> acte = delegate(string name, Encoding encoding) {
  48. act(string.Format("{0}", new object[]{name}), delegate() {
  49. return encoding;
  50. });
  51. };
  52.  
  53. Console.WriteLine(string.Format("OS: {0}", System.Environment.OSVersion.ToString()));
  54. Console.WriteLine();
  55. acti(1252);
  56. acti(932);
  57. acti(65001);
  58. acts("s-jis");
  59. acts("shift-jis");
  60. acts("cp932");
  61. acts("ms932");
  62. acts("windows-31j");
  63. acts("utf-7");
  64. acts("utf-8");
  65. acts("utf-16");
  66. acts("utf-16be");
  67. acts("utf-16le");
  68. acts("utf-32");
  69. acts("utf-32be");
  70. acts("utf-32le");
  71. acts("utf-7n");
  72. acts("utf-8n");
  73. acts("utf-16n");
  74. acts("utf-16ben");
  75. acts("utf-16len");
  76. acts("utf-32n");
  77. acts("utf-32ben");
  78. acts("utf-32len");
  79. acts("ucs-1");
  80. acts("ucs-2");
  81. acts("ucs-4");
  82. acts("S-JIS");
  83. acts("SHIFT-JIS");
  84. acts("CP932");
  85. acts("MS932");
  86. acts("WINDOWS-31J");
  87. acts("UTF-7");
  88. acts("UTF-8");
  89. acts("UTF-16");
  90. acts("UTF-16BE");
  91. acts("UTF-16LE");
  92. acts("UTF-32");
  93. acts("UTF-32BE");
  94. acts("UTF-32LE");
  95. acts("UTF-7N");
  96. acts("UTF-8N");
  97. acts("UTF-16N");
  98. acts("UTF-16BEN");
  99. acts("UTF-16LEN");
  100. acts("UTF-32N");
  101. acts("UTF-32BEN");
  102. acts("UTF-32LEN");
  103. acts("UCS-1");
  104. acts("UCS-2");
  105. acts("UCS-4");
  106. acte("Encoding.Default", Encoding.Default);
  107. acte("Encoding.UTF7", Encoding.UTF7);
  108. acte("Encoding.UTF8", Encoding.UTF8);
  109. acte("Encoding.Unicode", Encoding.Unicode);
  110. acte("Encoding.BigEndianUnicode", Encoding.BigEndianUnicode);
  111. acte("Encoding.UTF32", Encoding.UTF32);
  112. }
  113. }
Success #stdin #stdout 0.04s 19116KB
stdin
Standard input is empty
stdout
OS: Unix 4.9.0.12

Encoding.GetEncoding(1252) => CP1252, 1252, 1252,  (0), Western European (Windows), Windows-1252, iso-8859-1, Windows-1252
Encoding.GetEncoding(932) => CP932, 932, 932,  (0), Japanese (Shift-JIS), iso-2022-jp, iso-2022-jp, shift_jis
Encoding.GetEncoding(65001) => UTF8Encoding, 65001, 1200, EF BB BF (3), Unicode (UTF-8), utf-8, utf-8, utf-8
Encoding.GetEncoding("s-jis") => 's-jis' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("shift-jis") => CP932, 932, 932,  (0), Japanese (Shift-JIS), iso-2022-jp, iso-2022-jp, shift_jis
Encoding.GetEncoding("cp932") => 'cp932' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("ms932") => 'ms932' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("windows-31j") => 'windows-31j' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("utf-7") => UTF7Encoding, 65000, 1200,  (0), Unicode (UTF-7), utf-7, utf-7, utf-7
Encoding.GetEncoding("utf-8") => UTF8Encoding, 65001, 1200, EF BB BF (3), Unicode (UTF-8), utf-8, utf-8, utf-8
Encoding.GetEncoding("utf-16") => UnicodeEncoding, 1200, 1200, FF FE (2), Unicode, utf-16, utf-16, utf-16
Encoding.GetEncoding("utf-16be") => UnicodeEncoding, 1201, 1200, FE FF (2), Unicode (Big-Endian), utf-16BE, utf-16BE, utf-16BE
Encoding.GetEncoding("utf-16le") => UnicodeEncoding, 1200, 1200, FF FE (2), Unicode, utf-16, utf-16, utf-16
Encoding.GetEncoding("utf-32") => UTF32Encoding, 12000, 1200, FF FE 00 00 (4), Unicode (UTF-32), utf-32, utf-32, utf-32
Encoding.GetEncoding("utf-32be") => UTF32Encoding, 12001, 1200, 00 00 FE FF (4), Unicode (UTF-32 Big-Endian), utf-32BE, utf-32BE, utf-32BE
Encoding.GetEncoding("utf-32le") => UTF32Encoding, 12000, 1200, FF FE 00 00 (4), Unicode (UTF-32), utf-32, utf-32, utf-32
Encoding.GetEncoding("utf-7n") => 'utf-7n' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("utf-8n") => 'utf-8n' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("utf-16n") => 'utf-16n' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("utf-16ben") => 'utf-16ben' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("utf-16len") => 'utf-16len' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("utf-32n") => 'utf-32n' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("utf-32ben") => 'utf-32ben' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("utf-32len") => 'utf-32len' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("ucs-1") => 'ucs-1' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("ucs-2") => UnicodeEncoding, 1200, 1200, FF FE (2), Unicode, utf-16, utf-16, utf-16
Encoding.GetEncoding("ucs-4") => 'ucs-4' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("S-JIS") => 'S-JIS' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("SHIFT-JIS") => CP932, 932, 932,  (0), Japanese (Shift-JIS), iso-2022-jp, iso-2022-jp, shift_jis
Encoding.GetEncoding("CP932") => 'CP932' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("MS932") => 'MS932' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("WINDOWS-31J") => 'WINDOWS-31J' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UTF-7") => UTF7Encoding, 65000, 1200,  (0), Unicode (UTF-7), utf-7, utf-7, utf-7
Encoding.GetEncoding("UTF-8") => UTF8Encoding, 65001, 1200, EF BB BF (3), Unicode (UTF-8), utf-8, utf-8, utf-8
Encoding.GetEncoding("UTF-16") => UnicodeEncoding, 1200, 1200, FF FE (2), Unicode, utf-16, utf-16, utf-16
Encoding.GetEncoding("UTF-16BE") => UnicodeEncoding, 1201, 1200, FE FF (2), Unicode (Big-Endian), utf-16BE, utf-16BE, utf-16BE
Encoding.GetEncoding("UTF-16LE") => UnicodeEncoding, 1200, 1200, FF FE (2), Unicode, utf-16, utf-16, utf-16
Encoding.GetEncoding("UTF-32") => UTF32Encoding, 12000, 1200, FF FE 00 00 (4), Unicode (UTF-32), utf-32, utf-32, utf-32
Encoding.GetEncoding("UTF-32BE") => UTF32Encoding, 12001, 1200, 00 00 FE FF (4), Unicode (UTF-32 Big-Endian), utf-32BE, utf-32BE, utf-32BE
Encoding.GetEncoding("UTF-32LE") => UTF32Encoding, 12000, 1200, FF FE 00 00 (4), Unicode (UTF-32), utf-32, utf-32, utf-32
Encoding.GetEncoding("UTF-7N") => 'UTF-7N' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UTF-8N") => 'UTF-8N' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UTF-16N") => 'UTF-16N' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UTF-16BEN") => 'UTF-16BEN' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UTF-16LEN") => 'UTF-16LEN' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UTF-32N") => 'UTF-32N' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UTF-32BEN") => 'UTF-32BEN' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UTF-32LEN") => 'UTF-32LEN' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UCS-1") => 'UCS-1' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.GetEncoding("UCS-2") => UnicodeEncoding, 1200, 1200, FF FE (2), Unicode, utf-16, utf-16, utf-16
Encoding.GetEncoding("UCS-4") => 'UCS-4' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
Encoding.Default => UTF8Encoding, 65001, 1200, EF BB BF (3), Unicode (UTF-8), utf-8, utf-8, utf-8
Encoding.UTF7 => UTF7Encoding, 65000, 1200,  (0), Unicode (UTF-7), utf-7, utf-7, utf-7
Encoding.UTF8 => UTF8Encoding, 65001, 1200, EF BB BF (3), Unicode (UTF-8), utf-8, utf-8, utf-8
Encoding.Unicode => UnicodeEncoding, 1200, 1200, FF FE (2), Unicode, utf-16, utf-16, utf-16
Encoding.BigEndianUnicode => UnicodeEncoding, 1201, 1200, FE FF (2), Unicode (Big-Endian), utf-16BE, utf-16BE, utf-16BE
Encoding.UTF32 => UTF32Encoding, 12000, 1200, FF FE 00 00 (4), Unicode (UTF-32), utf-32, utf-32, utf-32