![]() 3 args expected,", argc, "are given.")Įxample: ❯. Unicode_name = directory + '/' + unicode_name Type = "DIR" if zip.getinfo(name).is_dir() else "FILE" Python3 script to unpack cp866 archive: #!/usr/bin/python3ĭef extract(filepath, directory = '', listonly = False): (At least on Linux, this has an advantage in that iconv is almost always available, and it always supports gb18030.) In case convmv is unavailable, script it: $ find. (Note: I had to install Encode::HanExtra from CPAN for the GB18030 support, and manually add use Encode::HanExtra to /usr/bin/convmv even though it's supposed to (Note that this only affects the find output, not files themselves.)įinally use convmv to convert the file names to UTF-8: $ convmv -r -f gb18030 -t utf-8 -notest. ![]() Verify that tools like iconv can successfully decode the names: $ find. I guess FreeBSD just calls it tar.) $ bsdtar xf gb18030.zip You can use this to your advantage.įirst, extract the archive using bsdtar, since the unzip tool seems to mangle the file names, while bsdtar will extract them raw. On most POSIX filesystems the filename is just a series of bytes and it's up to userspace to make any sense of it. The example gb18030.zip will extract the following file 【SSK字幕组】The Vampire Diaries 吸血鬼日记S06E12 If not os.path.exists(pathname) and pathname!= "": Parser.add_argument("file", help="process file.zip") Parser.add_argument("-l", help="list filenames in zipfile, do not unzip", action="store_true") Parser.add_argument("-encoding", help="encoding for filename, default gbk") Method 2 : Use a python script to unzip the file (reference ) #!/usr/bin/env python Method 1 : use unar utility sudo apt-get install unar I use the -O flag and: $ unzip -O GB18030 gb18030.zip -d target_dirĬreating: target_dir/【SSK字幕组】The Vampire Diaries 吸血鬼日记S06E12/ Which means that I simply try -O and it should work, because not a lot of people would create a. I CHARSET specify a character encoding for UNIX and other archives O CHARSET specify a character encoding for DOS, Windows and OS/2 archives I double-check the exact name of the encoding, as to not misspell it: Ĭhoosing between -O or -I according to instructions here: $ unzip -h The same method should work on FreeBSD because it only relies on widely available unzip tool. Here's what I do on Ubuntu 16.04 to unzip a zip in any encoding, as long as I know what that encoding is. So I think I have to solve first Chinese locale to verify when I get proper result, actually I can compare it. Then I downloaded file and try to "ls" to see proper characters, but not luck. The first thing, I would like to is to proper show Chinese names. Thanks, now trying on FREE BSD, where I am connecting using SSH from OSX (Terminal): # locale I tried similar with unzip, but I get similar problem. I tried on OSX: MBP1:test 2ge$ bsdtar xf gb18030.zip Question is - how to unpack that file in FreeBSD using unzip or other CLI utility to get proper encoded filename? I tried everything what I could, but result was never good. I know used encoding is GB18030 (Chinese) Here is example file, it contains one file Let's say I know encoding of those filenames, but I still dont know how to properly decompress them. ![]() I got ZIP file(s), which contains files, which filenames are in some encoding.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |