ZipConstants.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. // ZipConstants.cs
  2. //
  3. // Copyright (C) 2001 Mike Krueger
  4. // Copyright (C) 2004 John Reilly
  5. //
  6. // This file was translated from java, it was part of the GNU Classpath
  7. // Copyright (C) 2001 Free Software Foundation, Inc.
  8. //
  9. // This program is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public License
  11. // as published by the Free Software Foundation; either version 2
  12. // of the License, or (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. //
  23. // Linking this library statically or dynamically with other modules is
  24. // making a combined work based on this library. Thus, the terms and
  25. // conditions of the GNU General Public License cover the whole
  26. // combination.
  27. //
  28. // As a special exception, the copyright holders of this library give you
  29. // permission to link this library with independent modules to produce an
  30. // executable, regardless of the license terms of these independent
  31. // modules, and to copy and distribute the resulting executable under
  32. // terms of your choice, provided that you also meet, for each linked
  33. // independent module, the terms and conditions of the license of that
  34. // module. An independent module is a module which is not derived from
  35. // or based on this library. If you modify this library, you may extend
  36. // this exception to your version of the library, but you are not
  37. // obligated to do so. If you do not wish to do so, delete this
  38. // exception statement from your version.
  39. // HISTORY
  40. // 22-12-2009 DavidPierson Added AES support
  41. using System;
  42. using System.Text;
  43. using System.Threading;
  44. #if NETCF_1_0 || NETCF_2_0
  45. using System.Globalization;
  46. #endif
  47. namespace CommonMPQ.SharpZipLib.Zip
  48. {
  49. #region Enumerations
  50. /// <summary>
  51. /// Determines how entries are tested to see if they should use Zip64 extensions or not.
  52. /// </summary>
  53. public enum UseZip64
  54. {
  55. /// <summary>
  56. /// Zip64 will not be forced on entries during processing.
  57. /// </summary>
  58. /// <remarks>An entry can have this overridden if required <see cref="ZipEntry.ForceZip64"></see></remarks>
  59. Off,
  60. /// <summary>
  61. /// Zip64 should always be used.
  62. /// </summary>
  63. On,
  64. /// <summary>
  65. /// #ZipLib will determine use based on entry values when added to archive.
  66. /// </summary>
  67. Dynamic,
  68. }
  69. /// <summary>
  70. /// The kind of compression used for an entry in an archive
  71. /// </summary>
  72. public enum CompressionMethod
  73. {
  74. /// <summary>
  75. /// A direct copy of the file contents is held in the archive
  76. /// </summary>
  77. Stored = 0,
  78. /// <summary>
  79. /// Common Zip compression method using a sliding dictionary
  80. /// of up to 32KB and secondary compression from Huffman/Shannon-Fano trees
  81. /// </summary>
  82. Deflated = 8,
  83. /// <summary>
  84. /// An extension to deflate with a 64KB window. Not supported by #Zip currently
  85. /// </summary>
  86. Deflate64 = 9,
  87. /// <summary>
  88. /// BZip2 compression. Not supported by #Zip.
  89. /// </summary>
  90. BZip2 = 11,
  91. /// <summary>
  92. /// WinZip special for AES encryption, Now supported by #Zip.
  93. /// </summary>
  94. WinZipAES = 99,
  95. }
  96. /// <summary>
  97. /// Identifies the encryption algorithm used for an entry
  98. /// </summary>
  99. public enum EncryptionAlgorithm
  100. {
  101. /// <summary>
  102. /// No encryption has been used.
  103. /// </summary>
  104. None = 0,
  105. /// <summary>
  106. /// Encrypted using PKZIP 2.0 or 'classic' encryption.
  107. /// </summary>
  108. PkzipClassic = 1,
  109. /// <summary>
  110. /// DES encryption has been used.
  111. /// </summary>
  112. Des = 0x6601,
  113. /// <summary>
  114. /// RC2 encryption has been used for encryption.
  115. /// </summary>
  116. RC2 = 0x6602,
  117. /// <summary>
  118. /// Triple DES encryption with 168 bit keys has been used for this entry.
  119. /// </summary>
  120. TripleDes168 = 0x6603,
  121. /// <summary>
  122. /// Triple DES with 112 bit keys has been used for this entry.
  123. /// </summary>
  124. TripleDes112 = 0x6609,
  125. /// <summary>
  126. /// AES 128 has been used for encryption.
  127. /// </summary>
  128. Aes128 = 0x660e,
  129. /// <summary>
  130. /// AES 192 has been used for encryption.
  131. /// </summary>
  132. Aes192 = 0x660f,
  133. /// <summary>
  134. /// AES 256 has been used for encryption.
  135. /// </summary>
  136. Aes256 = 0x6610,
  137. /// <summary>
  138. /// RC2 corrected has been used for encryption.
  139. /// </summary>
  140. RC2Corrected = 0x6702,
  141. /// <summary>
  142. /// Blowfish has been used for encryption.
  143. /// </summary>
  144. Blowfish = 0x6720,
  145. /// <summary>
  146. /// Twofish has been used for encryption.
  147. /// </summary>
  148. Twofish = 0x6721,
  149. /// <summary>
  150. /// RC4 has been used for encryption.
  151. /// </summary>
  152. RC4 = 0x6801,
  153. /// <summary>
  154. /// An unknown algorithm has been used for encryption.
  155. /// </summary>
  156. Unknown = 0xffff
  157. }
  158. /// <summary>
  159. /// Defines the contents of the general bit flags field for an archive entry.
  160. /// </summary>
  161. [Flags]
  162. public enum GeneralBitFlags : int
  163. {
  164. /// <summary>
  165. /// Bit 0 if set indicates that the file is encrypted
  166. /// </summary>
  167. Encrypted = 0x0001,
  168. /// <summary>
  169. /// Bits 1 and 2 - Two bits defining the compression method (only for Method 6 Imploding and 8,9 Deflating)
  170. /// </summary>
  171. Method = 0x0006,
  172. /// <summary>
  173. /// Bit 3 if set indicates a trailing data desciptor is appended to the entry data
  174. /// </summary>
  175. Descriptor = 0x0008,
  176. /// <summary>
  177. /// Bit 4 is reserved for use with method 8 for enhanced deflation
  178. /// </summary>
  179. ReservedPKware4 = 0x0010,
  180. /// <summary>
  181. /// Bit 5 if set indicates the file contains Pkzip compressed patched data.
  182. /// Requires version 2.7 or greater.
  183. /// </summary>
  184. Patched = 0x0020,
  185. /// <summary>
  186. /// Bit 6 if set indicates strong encryption has been used for this entry.
  187. /// </summary>
  188. StrongEncryption = 0x0040,
  189. /// <summary>
  190. /// Bit 7 is currently unused
  191. /// </summary>
  192. Unused7 = 0x0080,
  193. /// <summary>
  194. /// Bit 8 is currently unused
  195. /// </summary>
  196. Unused8 = 0x0100,
  197. /// <summary>
  198. /// Bit 9 is currently unused
  199. /// </summary>
  200. Unused9 = 0x0200,
  201. /// <summary>
  202. /// Bit 10 is currently unused
  203. /// </summary>
  204. Unused10 = 0x0400,
  205. /// <summary>
  206. /// Bit 11 if set indicates the filename and
  207. /// comment fields for this file must be encoded using UTF-8.
  208. /// </summary>
  209. UnicodeText = 0x0800,
  210. /// <summary>
  211. /// Bit 12 is documented as being reserved by PKware for enhanced compression.
  212. /// </summary>
  213. EnhancedCompress = 0x1000,
  214. /// <summary>
  215. /// Bit 13 if set indicates that values in the local header are masked to hide
  216. /// their actual values, and the central directory is encrypted.
  217. /// </summary>
  218. /// <remarks>
  219. /// Used when encrypting the central directory contents.
  220. /// </remarks>
  221. HeaderMasked = 0x2000,
  222. /// <summary>
  223. /// Bit 14 is documented as being reserved for use by PKware
  224. /// </summary>
  225. ReservedPkware14 = 0x4000,
  226. /// <summary>
  227. /// Bit 15 is documented as being reserved for use by PKware
  228. /// </summary>
  229. ReservedPkware15 = 0x8000
  230. }
  231. #endregion
  232. /// <summary>
  233. /// This class contains constants used for Zip format files
  234. /// </summary>
  235. public sealed class ZipConstants
  236. {
  237. #region Versions
  238. /// <summary>
  239. /// The version made by field for entries in the central header when created by this library
  240. /// </summary>
  241. /// <remarks>
  242. /// This is also the Zip version for the library when comparing against the version required to extract
  243. /// for an entry. See <see cref="ZipEntry.CanDecompress"/>.
  244. /// </remarks>
  245. public const int VersionMadeBy = 51; // was 45 before AES
  246. /// <summary>
  247. /// The version made by field for entries in the central header when created by this library
  248. /// </summary>
  249. /// <remarks>
  250. /// This is also the Zip version for the library when comparing against the version required to extract
  251. /// for an entry. See <see cref="ZipInputStream.CanDecompressEntry">ZipInputStream.CanDecompressEntry</see>.
  252. /// </remarks>
  253. [Obsolete("Use VersionMadeBy instead")]
  254. public const int VERSION_MADE_BY = 51;
  255. /// <summary>
  256. /// The minimum version required to support strong encryption
  257. /// </summary>
  258. public const int VersionStrongEncryption = 50;
  259. /// <summary>
  260. /// The minimum version required to support strong encryption
  261. /// </summary>
  262. [Obsolete("Use VersionStrongEncryption instead")]
  263. public const int VERSION_STRONG_ENCRYPTION = 50;
  264. /// <summary>
  265. /// Version indicating AES encryption
  266. /// </summary>
  267. public const int VERSION_AES = 51;
  268. /// <summary>
  269. /// The version required for Zip64 extensions (4.5 or higher)
  270. /// </summary>
  271. public const int VersionZip64 = 45;
  272. #endregion
  273. #region Header Sizes
  274. /// <summary>
  275. /// Size of local entry header (excluding variable length fields at end)
  276. /// </summary>
  277. public const int LocalHeaderBaseSize = 30;
  278. /// <summary>
  279. /// Size of local entry header (excluding variable length fields at end)
  280. /// </summary>
  281. [Obsolete("Use LocalHeaderBaseSize instead")]
  282. public const int LOCHDR = 30;
  283. /// <summary>
  284. /// Size of Zip64 data descriptor
  285. /// </summary>
  286. public const int Zip64DataDescriptorSize = 24;
  287. /// <summary>
  288. /// Size of data descriptor
  289. /// </summary>
  290. public const int DataDescriptorSize = 16;
  291. /// <summary>
  292. /// Size of data descriptor
  293. /// </summary>
  294. [Obsolete("Use DataDescriptorSize instead")]
  295. public const int EXTHDR = 16;
  296. /// <summary>
  297. /// Size of central header entry (excluding variable fields)
  298. /// </summary>
  299. public const int CentralHeaderBaseSize = 46;
  300. /// <summary>
  301. /// Size of central header entry
  302. /// </summary>
  303. [Obsolete("Use CentralHeaderBaseSize instead")]
  304. public const int CENHDR = 46;
  305. /// <summary>
  306. /// Size of end of central record (excluding variable fields)
  307. /// </summary>
  308. public const int EndOfCentralRecordBaseSize = 22;
  309. /// <summary>
  310. /// Size of end of central record (excluding variable fields)
  311. /// </summary>
  312. [Obsolete("Use EndOfCentralRecordBaseSize instead")]
  313. public const int ENDHDR = 22;
  314. /// <summary>
  315. /// Size of 'classic' cryptographic header stored before any entry data
  316. /// </summary>
  317. public const int CryptoHeaderSize = 12;
  318. /// <summary>
  319. /// Size of cryptographic header stored before entry data
  320. /// </summary>
  321. [Obsolete("Use CryptoHeaderSize instead")]
  322. public const int CRYPTO_HEADER_SIZE = 12;
  323. #endregion
  324. #region Header Signatures
  325. /// <summary>
  326. /// Signature for local entry header
  327. /// </summary>
  328. public const int LocalHeaderSignature = 'P' | ('K' << 8) | (3 << 16) | (4 << 24);
  329. /// <summary>
  330. /// Signature for local entry header
  331. /// </summary>
  332. [Obsolete("Use LocalHeaderSignature instead")]
  333. public const int LOCSIG = 'P' | ('K' << 8) | (3 << 16) | (4 << 24);
  334. /// <summary>
  335. /// Signature for spanning entry
  336. /// </summary>
  337. public const int SpanningSignature = 'P' | ('K' << 8) | (7 << 16) | (8 << 24);
  338. /// <summary>
  339. /// Signature for spanning entry
  340. /// </summary>
  341. [Obsolete("Use SpanningSignature instead")]
  342. public const int SPANNINGSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24);
  343. /// <summary>
  344. /// Signature for temporary spanning entry
  345. /// </summary>
  346. public const int SpanningTempSignature = 'P' | ('K' << 8) | ('0' << 16) | ('0' << 24);
  347. /// <summary>
  348. /// Signature for temporary spanning entry
  349. /// </summary>
  350. [Obsolete("Use SpanningTempSignature instead")]
  351. public const int SPANTEMPSIG = 'P' | ('K' << 8) | ('0' << 16) | ('0' << 24);
  352. /// <summary>
  353. /// Signature for data descriptor
  354. /// </summary>
  355. /// <remarks>
  356. /// This is only used where the length, Crc, or compressed size isnt known when the
  357. /// entry is created and the output stream doesnt support seeking.
  358. /// The local entry cannot be 'patched' with the correct values in this case
  359. /// so the values are recorded after the data prefixed by this header, as well as in the central directory.
  360. /// </remarks>
  361. public const int DataDescriptorSignature = 'P' | ('K' << 8) | (7 << 16) | (8 << 24);
  362. /// <summary>
  363. /// Signature for data descriptor
  364. /// </summary>
  365. /// <remarks>
  366. /// This is only used where the length, Crc, or compressed size isnt known when the
  367. /// entry is created and the output stream doesnt support seeking.
  368. /// The local entry cannot be 'patched' with the correct values in this case
  369. /// so the values are recorded after the data prefixed by this header, as well as in the central directory.
  370. /// </remarks>
  371. [Obsolete("Use DataDescriptorSignature instead")]
  372. public const int EXTSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24);
  373. /// <summary>
  374. /// Signature for central header
  375. /// </summary>
  376. [Obsolete("Use CentralHeaderSignature instead")]
  377. public const int CENSIG = 'P' | ('K' << 8) | (1 << 16) | (2 << 24);
  378. /// <summary>
  379. /// Signature for central header
  380. /// </summary>
  381. public const int CentralHeaderSignature = 'P' | ('K' << 8) | (1 << 16) | (2 << 24);
  382. /// <summary>
  383. /// Signature for Zip64 central file header
  384. /// </summary>
  385. public const int Zip64CentralFileHeaderSignature = 'P' | ('K' << 8) | (6 << 16) | (6 << 24);
  386. /// <summary>
  387. /// Signature for Zip64 central file header
  388. /// </summary>
  389. [Obsolete("Use Zip64CentralFileHeaderSignature instead")]
  390. public const int CENSIG64 = 'P' | ('K' << 8) | (6 << 16) | (6 << 24);
  391. /// <summary>
  392. /// Signature for Zip64 central directory locator
  393. /// </summary>
  394. public const int Zip64CentralDirLocatorSignature = 'P' | ('K' << 8) | (6 << 16) | (7 << 24);
  395. /// <summary>
  396. /// Signature for archive extra data signature (were headers are encrypted).
  397. /// </summary>
  398. public const int ArchiveExtraDataSignature = 'P' | ('K' << 8) | (6 << 16) | (7 << 24);
  399. /// <summary>
  400. /// Central header digitial signature
  401. /// </summary>
  402. public const int CentralHeaderDigitalSignature = 'P' | ('K' << 8) | (5 << 16) | (5 << 24);
  403. /// <summary>
  404. /// Central header digitial signature
  405. /// </summary>
  406. [Obsolete("Use CentralHeaderDigitalSignaure instead")]
  407. public const int CENDIGITALSIG = 'P' | ('K' << 8) | (5 << 16) | (5 << 24);
  408. /// <summary>
  409. /// End of central directory record signature
  410. /// </summary>
  411. public const int EndOfCentralDirectorySignature = 'P' | ('K' << 8) | (5 << 16) | (6 << 24);
  412. /// <summary>
  413. /// End of central directory record signature
  414. /// </summary>
  415. [Obsolete("Use EndOfCentralDirectorySignature instead")]
  416. public const int ENDSIG = 'P' | ('K' << 8) | (5 << 16) | (6 << 24);
  417. #endregion
  418. #if NETCF_1_0 || NETCF_2_0
  419. // This isnt so great but is better than nothing.
  420. // Trying to work out an appropriate OEM code page would be good.
  421. // 850 is a good default for english speakers particularly in Europe.
  422. static int defaultCodePage = CultureInfo.CurrentCulture.TextInfo.ANSICodePage;
  423. #else
  424. /// <remarks>
  425. /// Get OEM codepage from NetFX, which parses the NLP file with culture info table etc etc.
  426. /// But sometimes it yields the special value of 1 which is nicknamed <c>CodePageNoOEM</c> in <see cref="Encoding"/> sources (might also mean <c>CP_OEMCP</c>, but Encoding puts it so).
  427. /// This was observed on Ukranian and Hindu systems.
  428. /// Given this value, <see cref="Encoding.GetEncoding(int)"/> throws an <see cref="ArgumentException"/>.
  429. /// So replace it with some fallback, e.g. 437 which is the default cpcp in a console in a default Windows installation.
  430. /// </remarks>
  431. static int defaultCodePage =
  432. // these values cause ArgumentException in subsequent calls to Encoding::GetEncoding()
  433. ((Thread.CurrentThread.CurrentCulture.TextInfo.OEMCodePage == 1) || (Thread.CurrentThread.CurrentCulture.TextInfo.OEMCodePage == 2) || (Thread.CurrentThread.CurrentCulture.TextInfo.OEMCodePage == 3) || (Thread.CurrentThread.CurrentCulture.TextInfo.OEMCodePage == 42))
  434. ? 437 // The default OEM encoding in a console in a default Windows installation, as a fallback.
  435. : Thread.CurrentThread.CurrentCulture.TextInfo.OEMCodePage;
  436. #endif
  437. /// <summary>
  438. /// Default encoding used for string conversion. 0 gives the default system OEM code page.
  439. /// Dont use unicode encodings if you want to be Zip compatible!
  440. /// Using the default code page isnt the full solution neccessarily
  441. /// there are many variable factors, codepage 850 is often a good choice for
  442. /// European users, however be careful about compatability.
  443. /// </summary>
  444. public static int DefaultCodePage {
  445. get {
  446. return defaultCodePage;
  447. }
  448. set {
  449. if ((value < 0) || (value > 65535) ||
  450. (value == 1) || (value == 2) || (value == 3) || (value == 42)) {
  451. throw new ArgumentOutOfRangeException("value");
  452. }
  453. defaultCodePage = value;
  454. }
  455. }
  456. /// <summary>
  457. /// Convert a portion of a byte array to a string.
  458. /// </summary>
  459. /// <param name="data">
  460. /// Data to convert to string
  461. /// </param>
  462. /// <param name="count">
  463. /// Number of bytes to convert starting from index 0
  464. /// </param>
  465. /// <returns>
  466. /// data[0]..data[count - 1] converted to a string
  467. /// </returns>
  468. public static string ConvertToString(byte[] data, int count)
  469. {
  470. if ( data == null ) {
  471. return string.Empty;
  472. }
  473. return Encoding.GetEncoding(DefaultCodePage).GetString(data, 0, count);
  474. }
  475. /// <summary>
  476. /// Convert a byte array to string
  477. /// </summary>
  478. /// <param name="data">
  479. /// Byte array to convert
  480. /// </param>
  481. /// <returns>
  482. /// <paramref name="data">data</paramref>converted to a string
  483. /// </returns>
  484. public static string ConvertToString(byte[] data)
  485. {
  486. if ( data == null ) {
  487. return string.Empty;
  488. }
  489. return ConvertToString(data, data.Length);
  490. }
  491. /// <summary>
  492. /// Convert a byte array to string
  493. /// </summary>
  494. /// <param name="flags">The applicable general purpose bits flags</param>
  495. /// <param name="data">
  496. /// Byte array to convert
  497. /// </param>
  498. /// <param name="count">The number of bytes to convert.</param>
  499. /// <returns>
  500. /// <paramref name="data">data</paramref>converted to a string
  501. /// </returns>
  502. public static string ConvertToStringExt(int flags, byte[] data, int count)
  503. {
  504. if ( data == null ) {
  505. return string.Empty;
  506. }
  507. if ( (flags & (int)GeneralBitFlags.UnicodeText) != 0 ) {
  508. return Encoding.UTF8.GetString(data, 0, count);
  509. }
  510. else {
  511. return ConvertToString(data, count);
  512. }
  513. }
  514. /// <summary>
  515. /// Convert a byte array to string
  516. /// </summary>
  517. /// <param name="data">
  518. /// Byte array to convert
  519. /// </param>
  520. /// <param name="flags">The applicable general purpose bits flags</param>
  521. /// <returns>
  522. /// <paramref name="data">data</paramref>converted to a string
  523. /// </returns>
  524. public static string ConvertToStringExt(int flags, byte[] data)
  525. {
  526. if ( data == null ) {
  527. return string.Empty;
  528. }
  529. if ( (flags & (int)GeneralBitFlags.UnicodeText) != 0 ) {
  530. return Encoding.UTF8.GetString(data, 0, data.Length);
  531. }
  532. else {
  533. return ConvertToString(data, data.Length);
  534. }
  535. }
  536. /// <summary>
  537. /// Convert a string to a byte array
  538. /// </summary>
  539. /// <param name="str">
  540. /// String to convert to an array
  541. /// </param>
  542. /// <returns>Converted array</returns>
  543. public static byte[] ConvertToArray(string str)
  544. {
  545. if ( str == null ) {
  546. return new byte[0];
  547. }
  548. return Encoding.GetEncoding(DefaultCodePage).GetBytes(str);
  549. }
  550. /// <summary>
  551. /// Convert a string to a byte array
  552. /// </summary>
  553. /// <param name="flags">The applicable <see cref="GeneralBitFlags">general purpose bits flags</see></param>
  554. /// <param name="str">
  555. /// String to convert to an array
  556. /// </param>
  557. /// <returns>Converted array</returns>
  558. public static byte[] ConvertToArray(int flags, string str)
  559. {
  560. if (str == null) {
  561. return new byte[0];
  562. }
  563. if ((flags & (int)GeneralBitFlags.UnicodeText) != 0) {
  564. return Encoding.UTF8.GetBytes(str);
  565. }
  566. else {
  567. return ConvertToArray(str);
  568. }
  569. }
  570. /// <summary>
  571. /// Initialise default instance of <see cref="ZipConstants">ZipConstants</see>
  572. /// </summary>
  573. /// <remarks>
  574. /// Private to prevent instances being created.
  575. /// </remarks>
  576. ZipConstants()
  577. {
  578. // Do nothing
  579. }
  580. }
  581. }