[
  {
    "Id": "244580",
    "ThreadId": "71691",
    "Html": "<p>Hi,</p>\r\n<p>I&nbsp;am trying to create a zip file of text files. The zip file contains Danish characters in filenames and also in textfiles. but when i create the file the danish character &quot;&oslash;&quot; is converted to &quot;o&quot;. I have also tried different options for&nbsp;</p>\r\n<p><span style=\"font-size:x-small\">ZipFile.ProvisionalAlternateEncoding =&nbsp;</span><span style=\"font-size:x-small\">System.Text.</span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">Encoding</span></span><span style=\"font-size:x-small\">.GetEncoding(</span><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">&quot;iso-8859-1&quot;</span></span><span style=\"font-size:x-small\">);</span></p>\r\n<p>filename &quot;inf&oslash;.txt&quot; changes to &quot;Inf&deg;.txt&quot;</p>\r\n<p><span style=\"font-size:x-small\">ZipFile.ProvisionalAlternateEncoding =&nbsp;</span><span style=\"font-size:x-small\">System.Text.</span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">Encoding</span></span><span style=\"font-size:x-small\">.GetEncoding(</span><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">1252</span></span><span style=\"font-size:x-small\">);</span></p>\r\n<p>filename &quot;inf&oslash;.txt&quot; changes to &quot;Inf&deg;.txt&quot;</p>\r\n<p><span style=\"font-size:x-small\">ZipFile.ProvisionalAlternateEncoding =&nbsp;</span><span style=\"font-size:x-small\">System.Text.</span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">Encoding</span></span><span style=\"font-size:x-small\">.GetEncoding(</span><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">850</span></span><span style=\"font-size:x-small\">);</span></p>\r\n<p>filename &quot;inf&oslash;.txt&quot; changes to &quot;Inf&cent;.txt&quot;</p>\r\n<p><span style=\"font-size:x-small\">ZipFile.ProvisionalAlternateEncoding =&nbsp;</span><span style=\"font-size:x-small\">System.Text.</span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">Encoding</span></span><span style=\"font-size:x-small\">.GetEncoding(</span><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">850</span></span><span style=\"font-size:x-small\">);</span></p>\r\n<p>filename &quot;inf&oslash;.txt&quot; changes to &quot;Info.txt&quot;</p>\r\n<p><span style=\"font-size:x-small\">ZipFile.ProvisionalAlternateEncoding =&nbsp;</span><span style=\"font-size:x-small\">System.Text.</span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">Encoding</span></span><span style=\"font-size:x-small\">.Default</span><span style=\"font-size:x-small\">;</span></p>\r\n<p>filename &quot;inf&oslash;.txt&quot; changes to &quot;Info.txt&quot;</p>\r\n<p>also tried the work item <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=7791\">http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=7791</a></p>\r\n<p>Entries in my Web.config&nbsp; for encoding are:</p>\r\n<p><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">&lt;font size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;\r\n<p>&lt;</p>\r\n&lt;/font&gt;&lt;/font&gt;</span>&lt;font size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;</span>\r\n<p><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">globalization</span></span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\"> </span></span><span style=\"font-size:x-small;color:#ff0000\"><span style=\"font-size:x-small;color:#ff0000\">requestEncoding</span></span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">=</span></span><span style=\"font-size:x-small\">&quot;</span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">ISO-8859-1</span></span><span style=\"font-size:x-small\">&quot;</span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\"> </span></span><span style=\"font-size:x-small;color:#ff0000\"><span style=\"font-size:x-small;color:#ff0000\">responseEncoding</span></span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">=</span></span><span style=\"font-size:x-small\">&quot;</span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">ISO-8859-1</span></span><span style=\"font-size:x-small\">&quot;</span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\"> </span></span><span style=\"font-size:x-small;color:#ff0000\"><span style=\"font-size:x-small;color:#ff0000\">fileEncoding</span></span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">=</span></span><span style=\"font-size:x-small\">&quot;</span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">ISO-8859-1</span></span><span style=\"font-size:x-small\">&quot;</span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\"> </span></span><span style=\"font-size:x-small;color:#ff0000\"><span style=\"font-size:x-small;color:#ff0000\">culture</span></span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">=</span></span><span style=\"font-size:x-small\">&quot;</span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">en-GB</span></span><span style=\"font-size:x-small\">&quot;</span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">/&gt;</span></span></p>\r\n<p><span style=\"color:#000000\">&nbsp;</span></p>\r\n<p><span style=\"color:#000000\">following is the code for generating zip file.</span></p>\r\n</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\"><span style=\"font-size:x-small\"><p>Response.Clear();</p><p>Response.ContentType =<span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">&quot;application/zip&quot;</span></span><span style=\"font-size:x-small\">;</span></p><span style=\"color:Blue\">&lt;font size=&quot;2&quot;&gt;<p>Response.AddHeader(</p>&lt;/font&gt;<span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">&quot;content-disposition&quot;</span></span><span style=\"font-size:x-small\">, </span><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">&quot;attachment; filename=Graveringsordre</span></span><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">.zip&quot;</span></span><span style=\"font-size:x-small\">);</span></span></span><p><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">&quot;content-disposition&quot;</span></span><span style=\"font-size:x-small\">, </span><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">&quot;attachment; filename=Graveringsordre</span></span><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">.zip&quot;</span></span><span style=\"font-size:x-small\">);</span></p></span></pre>\r\n<pre><span style=\"color:Blue\">using</span> (ZipFile zip = <span style=\"color:Blue\">new</span> Ionic.Zip.ZipFile())\r\n            {</pre>\r\n<pre>\t     // I tried different encoding options as specified above\r\n              zip.ProvisionalAlternateEncoding = System.Text.Encoding.Default;\r\n              <span style=\"color:Blue\">#region</span> Add Strings in Text files and zip them\r\n\r\n              <span style=\"color:Green\">// code for adding text files</span>\r\n              zip.AddFileFromString(<span style=\"color:#A31515\">&quot;Inf&oslash;.txt&quot;</span>, <span style=\"color:#A31515\">&quot;Graveringsordre&quot;</span>, sb_Info.ToString());\r\n              zip.AddFileFromString(<span style=\"color:#A31515\">&quot;navne.txt&quot;</span>, <span style=\"color:#A31515\">&quot;Graveringsordre&quot;</span>, sb_1.ToString());\r\n              zip.Save(Response.OutputStream);\r\n            }\r\n            Response.End();            \r\n</pre>\r\n<pre>Please tell me where I am doing anything wrong?</pre>\r\n<pre>Thanks in advance.</pre>\r\n<pre>Best regards,</pre>\r\n<pre>Qaisar</pre>\r\n</div>",
    "PostedDate": "2009-10-12T02:29:13.43-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "244587",
    "ThreadId": "71691",
    "Html": "<p>Q, how do you unzip?&nbsp; What tool are you using?</p>\r\n<p>How do you determine that the filename &quot;changes&quot;?</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-12T03:00:07.337-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "244593",
    "ThreadId": "71691",
    "Html": "<p>Did you read <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/aecbb638-1ecf-807e-b933-5bb1a2a95e81.htm\">the doc on ProvisionalAlternateEncoding</a> ?&nbsp; If not, I suggest you do that now.</p>\r\n<p>Any zip file that you produce using ProvisionalAlternateEncoding will be non-compliant, if the encoding is not one of (UTF-8, IBM437).&nbsp; And, when reading such a zip file, you need to specify to the zip tool or library which encoding was used to create the zip file.&nbsp; This is explained in the doc.</p>\r\n<p>Suppose you create a zipfile, that contains entries with filenames that have Danish characters.&nbsp; If you use encoding iso-8859-1, the filenames will be correctly encoded in the zip. &nbsp;But, to read that zipfile correctly, you have to specify the same codepage at the time you read it.&nbsp; In other words, if you explicitly specify the codepage when you create the zipfile, you must explicitly specify the same codepage when reading the zipfile.&nbsp; The way you specify the code page varies depending on the tool or library you use to read the zip.&nbsp; In DotNetZip, it's a parameter on the ZipFile constructor.&nbsp;&nbsp; It isn't possible with windows explorer, as far as I know, to specify an explicit codepage.&nbsp; Maybe that is why you are not getting the results you expect.&nbsp;&nbsp; If try to read that zip file with Windows Explorer or another application that is not flexible with respect to the codepage used to decode filenames in zipfiles, you will get a filename like &quot;Inf&deg;.txt&quot;.</p>\r\n<p>To get what you want, use the property UseUnicodeAsNecessary - this produces a UTF-8 encoded zipfile, which is compliant. It will be readable with compliant zip tools.&nbsp;</p>\r\n<p>like so:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>    <span style=\"color:Blue\">using</span> (ZipFile zip = <span style=\"color:Blue\">new</span> Ionic.Zip.ZipFile())\r\n    {\r\n        <span style=\"color:Green\">// zip.ProvisionalAlternateEncoding = System.Text.Encoding.GetEncoding(&quot;iso-8859-1&quot;);</span>\r\n        zip.UseUnicodeAsNecessary = <span style=\"color:Blue\">true</span>;\r\n\r\n        <span style=\"color:Green\">// code for adding text files</span>\r\n        zip.AddEntry(<span style=\"color:#A31515\">&quot;Inf&oslash;.txt&quot;</span>, <span style=\"color:#A31515\">&quot;Graveringsordre&quot;</span>, s1);\r\n        zip.AddEntry(<span style=\"color:#A31515\">&quot;navne.txt&quot;</span>, <span style=\"color:#A31515\">&quot;Graveringsordre&quot;</span>, s2);\r\n\r\n        zip.Save( ... );\r\n    }\r\n</pre>\r\n</div>\r\n<p>If you find that doesn't work, with whatever you use to read your zip files,, then you can use zip.ProvisionalAlternateEncoding = System.Text.Encoding.GetEncoding(&quot;iso-8859-1&quot;);,&nbsp; but you must also specify that code page when you read the zipfile, in the tool you use to read it.</p>\r\n<p>I wrote a bunch of material discussing codepages, compliance, and interoperability. &nbsp;It's all in the <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/aecbb638-1ecf-807e-b933-5bb1a2a95e81.htm\">documentation</a>.</p>\r\n<p>Good luck.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-12T03:37:05.407-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "244599",
    "ThreadId": "71691",
    "Html": "<p>Dear Chesso,</p>\r\n<p>Thank You very much for&nbsp;the good work and&nbsp;quick reply.</p>\r\n<p>Its my fault. Actually I had winrar3.40 installed on my computer. I updated to the latest version and now its working fine.</p>\r\n<p>Your DotNetZip library is fantastic.</p>\r\n<p>ThankYou very much for the help.</p>\r\n<p>Best Regards,</p>\r\n<p>Qaisar</p>",
    "PostedDate": "2009-10-12T04:08:35.6-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]