SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php ZipArchive() - special characters not displayed correctly when listing filenames

    I have tried EVERYTHING and asked the question on 3 different php forums but nobody could come up with a solution. I'm desperate !

    I have a FTP on a dedicated server where my users uploads mp3 in zip files. I use a php page to display the list of the filenames inside the archive.

    Problem is that when some of the mp3 filenames have accents (like ) then it is not displayed correctly even if the page is set to use UTF8.

    for exemple, "" will become " "
    "" will become " "
    "" will become " "

    Code:
    <?php
    header('Content-Type: text/html; charset=utf-8');
    
    setlocale(LC_ALL, 'fr_FR');
    
    echo "
    <html>
    <head>
    <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />
    </head>
    <body>";
    
    $downloadlink = "dl/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 <br>";
    }
    }
    
    echo "</body></html>";
            ?>

  2. #2
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    basename is locale dependant. check your default locale setting first.

    Code:
    echo setlocale(LC_ALL, 0);

  3. #3
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo setlocale(LC_ALL, 0);
    result is:
    C
    Not sure what it means and how it is revelent for my problem...

  4. #4
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try setting your locale to utf8.

    setlocale(LC_ALL, 'en_US.UTF-8');

  5. #5
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just tried it, and it doesnt change anything

    i have also tried with fr_CA.UTF-8 which should be the correct encoding for my files and my server


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •