NSTask unzip skipped filename with special characters ( å, ä, ö )

185 Views Asked by At

HI I'm new to mac development. I'm using NSTask to unzip files. When unzip encounters image names with special characters ( å, ä, ö ), the files gets skipped. Is there an encoding that I need to specify or if someone can point me to the issue that would be great. Thanks in advance.

NSTask *unzip = [[NSTask alloc] init];
[unzip setLaunchPath:@"/usr/bin/unzip"];
[unzip setArguments:[NSArray arrayWithObjects:@"-u", @"-d", destination, zipFile, nil]];
NSPipe *aPipe = [[NSPipe alloc] init];
[unzip setStandardOutput:aPipe];
[unzip launch];
[unzip waitUntilExit];
[unzip release];

EDIT:

I also found the following from the unzip man page.

https://docs.oracle.com/cd/E88353_01/html/E37839/unzip-1.html

-U
       --unicode
              [UNICODE_SUPPORT]  Control UTF-8 handling.  When UNICODE_SUPPORT
              is available, -U forces UnZip to escape all non-ASCII characters
              from UTF-8 coded filenames as "#Uxxxx' (for UCS-2 characters, or
              "#Lxxxxxx" for  Unicode  codepoints  needing  3  octets).   This
              option  is  provided  mainly  for debugging, when the fairly new
              UTF-8 support is suspected of mangling extracted filenames.

              -UU disables the recognition of UTF-8  encoded  filenames.   The
              handling  of  filename  codings  within  UnZip falls back to the
              behavior of pre-Unicode versions.

              [old, obsolete usage] Leave filenames uppercase  if  created  on
              MS-DOS, VMS, and so on.  See -L.

-U is the aoption to be added how do i add the options in the code?

0

There are 0 best solutions below