GithubHelp home page GithubHelp logo

Comments (12)

mattconnolly avatar mattconnolly commented on August 17, 2024

I did notice that, but it hasn't been a problem for me.

Could zip files have their file names in another character set?

Perhaps it would be better to make the filename encoding a property that the user can set. That way, if they know the file is coming from windows, they can use NSWindowsCP1252StringEncoding for example.

Thoughts?

from ziparchive.

mronkko avatar mronkko commented on August 17, 2024

User configurable encoding would work for me. In my application I do not know what files the users will be working with, thought so I would just set it to UTF8. Wouldn't UTF8 be a good default? I am not expert on this, but it should be backwards compatible with ASCII and therefore if a filename really is ASCII, decoding it with UTF8 produces the correct result.

Here is a test case

https://dl.dropboxusercontent.com/u/694399/5XVQU5E3.zip

The file opens on my Mac, but the filename is garbage.

Mikkos-MacBook-Pro:Downloads mronkko$ unzip -l 5XVQU5E3.zip 
Archive:  5XVQU5E3.zip
  Length     Date   Time    Name
 --------    ----   ----    ----
  2866661  08-06-13 14:24   �и�е� Ю, �ан��л� �а�дона - ��нов� �изики пол�п�оводников - 2002 [05].pdf
 --------                   -------
  2866661                   1 file

This does not open with the current version of ZipArchive, but it opens with the same garbage filename when I change the encoding to NSUTF8StringEncoding

from ziparchive.

mattconnolly avatar mattconnolly commented on August 17, 2024

What an interesting filename. I don't know what encoding that is in. I think it's lucky that UTF-8 accepted it.

UTF-8 has some rules about what is valid. You can't expect to throw random bytes at it and expect it to mean something.

Would you happen to know what language that file is in, and then guess the correct encoding?

Certainly looks like a configurable option is the way to go. Perhaps you could guess the encoding based on the user's locale settings or something.

from ziparchive.

mronkko avatar mronkko commented on August 17, 2024

The filename is in Russian and cyrilic characters. It may work with NSWindowsCP1251StringEncoding, but I have not tested it.

User configurable encoding is a good idea because it would allow fallback options or even presenting the user an UI to choose the correct encoding if it cannot be determined otherwise.

from ziparchive.

mattconnolly avatar mattconnolly commented on August 17, 2024

Added property in 11c879a

Can you please verify this works for you?

from ziparchive.

mronkko avatar mronkko commented on August 17, 2024

Works just fine.

I will include this in the test version of my app and let you know if any of my testers encounter any problems.

On Aug 7, 2013, at 15:07 , Matt Connolly <[email protected]mailto:[email protected]>
wrote:

Added property in 11c879ahttps://github.com/mattconnolly/ZipArchive/commit/11c879a8b7b6c57f1ae45d2aa7fd98d44149b02e

Can you please verify this works for you?


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-22246354.

from ziparchive.

mattconnolly avatar mattconnolly commented on August 17, 2024

Released updated cocoapod, version 1.2.0 including this update.

from ziparchive.

mronkko avatar mronkko commented on August 17, 2024

This change or some other change has caused some problems for some of my testers and I have myself confirmed cases where after encoding filenames with UTF8, the zipfile can no longer be opened either with ZipArchive on iOS or on my Mac.

I am still investigating the exact cause.

from ziparchive.

mattconnolly avatar mattconnolly commented on August 17, 2024

Can you please clarify: If you set the stringEncoding to ascii it works, right? Like so:

    ZipArchive* zip;
    zip.stringEncoding = NSASCIIStringEncoding;

from ziparchive.

mronkko avatar mronkko commented on August 17, 2024

I need to do some more tests, and will post the results.

from ziparchive.

mronkko avatar mronkko commented on August 17, 2024

I created an empty project and setup ZipArchive with CocoaPods and this setup works just fine with UTF8, so the corrupted zip files are caused by something else.

from ziparchive.

mronkko avatar mronkko commented on August 17, 2024

I have done some testing and it seems that I cannot create valid zip archives with any version of ZipArchive installed with cocoapods. Unzipping existing archives works just fine.

I set up a a very simple iOS app that compresses a PDF file in the AppDelegate and then uncompresses the same file. The uncompressing part fails and when I run this in the simulator, I can uncompress the archive, but the file inside is corrupted.

https://dl.dropboxusercontent.com/u/694399/ZA.zip

from ziparchive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.