0

I use ZipArchive(); to list the file names inside a Zip archive (uploaded on FTP, not created by server).

Problem is that the file names contain french caracters (accents like é à ô â à è) that are not displayed proprely. Instead i get a "�" symbol.

The page is encoded in utf8 and the rest of the script doesnt have any problem with accents

i tried running htmlentities() or utf8_encode() on $toune but it didnt help...

here's my code:

header('Content-Type: text/html; charset=utf-8');
$downloadlink = "pp/86 Crew - 2000 - Bad Bad Reggae.zip";
            $za = new ZipArchive();
            $za->open($downloadlink);
            for( $i = 0; $i < $za->numFiles; $i++ ){
                $stat = $za->statIndex( $i );
                $tounes = array( basename( $stat['name'] ) . PHP_EOL );
                foreach($tounes as $toune) {
                echo $toune;
                }
            }
8
  • Use iconv or mb_string. Encode them to utf-8, if needed.
    – BlitZ
    Jun 18, 2013 at 10:45
  • i'm confused... example please ? Jun 18, 2013 at 22:10
  • $tounes = array( basename( iconv('YourCharSetName', 'UTF-8', $stat['name']) ) . PHP_EOL );
    – BlitZ
    Jun 19, 2013 at 1:56
  • "YourCharSetName" is supposed to be the charset of the zip's filenames ? but how can i know what is the characters encoding of the filenames inside the ZIP archive ? Jun 19, 2013 at 2:15
  • Well, it is french, as you mentioned. Which used for it im most of the times?
    – BlitZ
    Jun 19, 2013 at 2:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.