Jump to content

Detect codepage to use, read it from system? (for ZIP files)


Recommended Posts

I am moved a clients system from one ISP running PHP5.5 to a new ISP running PHP7.2

My problem is coding of filenames when I create zip files, with non English letters. I found this to work with CP775.

$dl[$z]=iconv("UTF-8", "CP775//TRANSLIT", $dl[$z]);
            $zip->addFile($file, implode("/", $dl));

Now, would it be possible to detect what CP to use from the system?

I found mb_detect_encoding but it does not tell me much.

No, that is not what I am looking for.

I made a script so I could try multiple Codepages at once, for the download, and started figuring out which one it right. Knowing that I am in the Baltics then 775 and 1257 were obvuious choices after some failures, and it work - here for now. But how can I get to know what CP to use in other cases?

Using no CP conversion on one server causes the filenames to contain wrong charactes, e.g. ü becomes _ (underscore) etc.

On another server it is not an issue and I can use the filename directly

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.