When you try to extract zipped file, sometimes it shows an error like below.
unzip error 22: invalid argument
"Windows can decompose it. But Mac couldn't ..."
It is strange. But there is a reason.
Today I introduce the reason of unzip error 22
in MacOS.
Error
First, we should understand how the error occurs.
As I wrote before, the error occurs when we try to extract zipped file in MacOS.
unzip error 22: invalid argument
Then we failed extracting.
Cause is update of MacOS ?
This error was reported on October 10th 2019.
It was just after updating MacOS Catalina.
Upgraded to MacOS Catalina and now I cannot unzip any zipped file. I had no problems before. Also, moving the file or redownloading is not fixing it. Multiple files of different sizes failed. MacBook user here.?
If it is due to OS Catalina, it seems that we can do nothing after updating.
But there is a solution for this issue.
Root cause is character encoding
This unzip error happens only when we try to unzip zipped file that was composed by Windows.
The error is not occured by zipped file of MacOS.
It means that the error is caused by composing difference btween Windows and MacOS.
The difference is character encoding.
Windows uses local character like Shift-JIS.
And MacOS and other Unix use UTF-8.
Sometimes this difference makes error. And unzip error 22
is also caused by character encoding.
MacOS function decompose zipped file with UTF-8.
When zipped file contains local character encoding, it would fail.
It is same as previous article.
-
File name is garbled when we decompressed zip file.
So solution is also same.
Solution1: Use decomposing software
Instead of MacOS function, you can use decomposing software. So it checks character encoding and decompose correctly.
There are some decomposing software like "Zip File Unarchiver" and "The Unarchiver".
Refference
Solution2: composing settings
You can also avoid the error with using UTF-8 composing settings.
You can set cu=on
in parameter on 7-Zip. Then it would compose with UTF-8.
MacOS can decompose UTF-8-zipped file.
Finally
unzip error 22
of MacOS is caused by character encoding difference between Windows and MacOS.- You can avoid the error by using decomposing software or using composing settings.