/    Sign up×
Community /Pin to ProfileBookmark

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>”;
?>[/CODE]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@elvedinAug 21.2015 — Have you ever solved this issue?
×

Success!

Help @anarchoi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...