ZipFile.Static.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Ionic.Zip
  5. {
  6. partial class ZipFile
  7. {
  8. private static System.Text.Encoding _defaultEncoding = null;
  9. private static bool _defaultEncodingInitialized = false;
  10. /// <summary>
  11. ///
  12. ///
  13. /// Static constructor for ZipFile
  14. /// </summary>
  15. /// <remarks>
  16. /// Code Pages 437 and 1252 for English are same
  17. /// Code Page 1252 Windows Latin 1 (ANSI) - <see href="https://msdn.microsoft.com/en-us/library/cc195054.aspx"/>
  18. /// Code Page 437 MS-DOS Latin US - <see href="https://msdn.microsoft.com/en-us/library/cc195060.aspx"/>
  19. /// </remarks>
  20. static ZipFile()
  21. {
  22. System.Text.Encoding ibm437 = null;
  23. try
  24. {
  25. ibm437 = System.Text.Encoding.GetEncoding("IBM437");
  26. }
  27. catch (Exception /*e*/)
  28. {
  29. }
  30. #if !WINDOWS_PHONE_APP
  31. if (ibm437 == null)
  32. {
  33. try
  34. {
  35. ibm437 = System.Text.Encoding.GetEncoding(1252);
  36. }
  37. catch (Exception /*e*/)
  38. {
  39. }
  40. }
  41. #endif
  42. _defaultEncoding = ibm437;
  43. }
  44. /// <summary>
  45. /// The default text encoding used in zip archives. It is numeric 437, also
  46. /// known as IBM437.
  47. /// </summary>
  48. /// <seealso cref="Ionic.Zip.ZipFile.AlternateEncoding"/>
  49. public static System.Text.Encoding DefaultEncoding
  50. {
  51. get
  52. {
  53. return _defaultEncoding;
  54. }
  55. set
  56. {
  57. if (_defaultEncodingInitialized)
  58. {
  59. return;
  60. }
  61. _defaultEncoding = value;
  62. _defaultEncodingInitialized = true;
  63. }
  64. }
  65. }
  66. }