The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



Вариант для распечатки  
Пред. тема | След. тема 
Форум Разговоры, обсуждение новостей
Режим отображения отдельной подветви беседы [ Отслеживать ]

Оглавление

Раздел полезных советов: Работа с русскими именами файлов в ..., auto_tips (?), 30-Ноя-10, (0) [смотреть все] +3

Сообщения [Сортировка по времени | RSS]


30. "Работа с русскими именами файлов в ZIP и UNZIP под nix"  +/
Сообщение от prof_alex (?), 11-Дек-10, 01:57 
Что-то не пойму. Собрал unzip из calculate

emerge -vp unzip

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] app-arch/unzip-6.0-r9  USE="bzip2 natspec unicode" 0 kB [1]

Total: 1 package (1 reinstall), Size of downloads: 0 kB
Portage tree and overlays:
[0] /usr/portage
[1] /var/lib/layman/calculate

Всё вроде есть:
natspec -i
libnatspec 0.2.6, compiled Aug  3 2010
=== Overall information ===
Current locale: ru_RU.UTF-8
System locale: ru_RU.UTF-8
Filename encoding in iconv/nls form: utf8
Country ID (for DOS): -1
Codepage of DOS: 866
Charset of 'UNIX' system: UTF8
Charset of 'WIN' system: CP1251
Charset of 'DOS' system: IBM866
Charset of 'MAC' system: MACCYRILLIC
After setlocale:
    nl_langinfo(CODESET): UTF-8
    natspec_get_charset: UTF8
Current locale is in UTF8 encoding

unzip -l
UnZip 6.00 of 20 April 2009, by ALT Linux Team.  Original by Info-ZIP.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment only
  -v  list verbosely/show version info       -T  timestamp archive to latest
  -x  exclude files that follow (in xlist)   -d  extract files into exdir
modifiers:
  -n  never overwrite existing files         -q  quiet mode (-qq => quieter)
  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files
  -j  junk paths (do not make directories)   -aa treat ALL files as text
  -U  use escapes for all non-ASCII Unicode  -UU ignore any Unicode fields
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
  -O CHARSET  specify a character encoding for DOS, Windows and OS/2 archives
  -I CHARSET  specify a character encoding for UNIX and other archives
See "unzip -hh" or unzip.txt for more help.  Examples:
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -p foo | more  => send contents of foo.zip via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer

А листинг с вопросами:
unzip -lO IBM866 SP\ 41\ 108.zip
Archive:  SP 41 108.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
   448972  10-10-2008 09:46   ???? 41-108-2004 ???????????????????????? ????????????????????????????.pdf
---------                     -------
   448972                     1 file

Написал своё, без natspec на python:
./pyunzip.py -l SP\ 41\ 108.zip
Archive:  SP 41 108.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
   448972  2008-10-10 09:46   СП 41-108-2004 ПОКВАРТИРНОЕ ТЕПЛОСНАБЖЕНИЕ.pdf
---------                     -------
   448972                     1 files

Можно привести примеры использования?

Ответить | Правка | Наверх | Cообщить модератору

31. "Работа с русскими именами файлов в ZIP и UNZIP под nix"  +/
Сообщение от Natrioemail (?), 11-Дек-10, 09:52 
Чуть выше я уже писал, что unzip/zipinfo, собранный без опции NO_SETLOCALE, при выводе в консоль заменяет все не-ASCII символы вопросительными знаками. Мой патч к unzip
http://pda.opennet.ru/soft/zip_rus/unzip60-natspec-mod.diff.gz
как раз и отличается от альтовского патча включением этой опции. Другой способ её включить – задать для сборки unzip переменную окружения
   LOCAL_UNZIP="-DNO_SETLOCALE"
Опции -I и -O нужны ТОЛЬКО для случаев, когда вам требуется задать кодировки отличные от тех, что выдаёт natspec. Если кодировка архива совпадает с определённой natspec DOS-кодировкой, то никаких дополнительных ключей не требуется:
   $ unzip -l ../test.zip
   Archive:  ../test.zip
     Length      Date    Time    Name
   ---------  ---------- -----   ----
           0  12-03-2010 21:23   тест/
           7  12-03-2010 21:23   тест/эюя
           7  12-03-2010 21:23   тест/абв
          17  12-10-2010 11:49   Шах и мат.txt
   ---------                     -------
          31                     4 files
Ответить | Правка | Наверх | Cообщить модератору

Архив | Удалить

Рекомендовать для помещения в FAQ | Индекс форумов | Темы | Пред. тема | След. тема




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру