P
P
ppa2013-06-16 13:34:16
PHP
ppa, 2013-06-16 13:34:16

ZipArchive and encoding

I know it was a similar question, but still. There is a code:

$zip = new ZipArchive();
$zip->open(dirname(__FILE__).'/test.zip', ZIPARCHIVE::CREATE);
$name = 'файл 1';
$zip->addFile($name);
$zip->close();
which adds the file "file 1" to the archive. But due to encoding problems, the name is "файÐ" 1". The second day I fight, I did not find a solution, except for a crutch in the form of exec ('zip ....'). Maybe someone here can help.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
WEBIVAN, 2013-06-16
@ppa

Set file names in a different encoding?
The displayed is very similar to the situation when the name should be in co1251, but written in utf8

E
EugeneOZ, 2013-06-16
@EugeneOZ

It's funny, Google found my own answer on SO:
stackoverflow.com/a/6163463/680786

L
lefin17, 2019-01-24
@lefin17

The problem with the Russian encoding may be related to the locale under which php + nginx (apache) works,
find out the locale from me like this:

LANG=
LC_CTYPE="POSIX" 
LC_NUMERIC="POSIX"...

at the server command prompt, run $locale - for comparison
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8" 
LC_NUMERIC="en_US.UTF-8" ...

Further analysis of the flight on unixes led to the use of such a construction
where env - defines the language (locale) of the environment under which you need to execute the
nice command - execution with a reduced priority so as not to hang everything
7za - a built-in fancy archiver whose abilities are enough to solve the problem
further in the manuals for 7za (7zip) but the meaning is from utf8 for windows, we create an archive with the name and from the files located in a specific folder.
I managed. Good luck. Years go by, the problem occurs. Thanks to colleagues for their participation in solving the problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question