gdfhghjdfghgfhf Posted June 20, 2013 Share Posted June 20, 2013 I use ZipArchive(); to list the file names inside a Zip archive (uploaded on FTP by different users, not created by server). Problem is that some of 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;}} Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/ Share on other sites More sharing options...
gizmola Posted June 21, 2013 Share Posted June 21, 2013 This is an interesting question. Apparently, from a quick google, there may not be a clear solution since the codepage of the character set used isn't stored in the zip file, unless the sources I referenced are incorrect. One obvious issue to start with is that the base name() function is "locale aware" so you would want to setlocale appropriately. I would suggest starting with that issue. Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1437168 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted June 21, 2013 Author Share Posted June 21, 2013 One obvious issue to start with is that the base name() function is "locale aware" so you would want to setlocale appropriately. I would suggest starting with that issue. Sorry i'm not sure what you mean :/ ... still a beginner with the advanced php stuff Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1437170 Share on other sites More sharing options...
richei Posted June 21, 2013 Share Posted June 21, 2013 use setlocale(), just be careful of what category you use - http://us3.php.net/manual/en/function.setlocale.php Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1437275 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted June 23, 2013 Author Share Posted June 23, 2013 use setlocale(), just be careful of what category you use - http://us3.php.net/manual/en/function.setlocale.php What category should I use ? LC_COLLATE ? Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1437455 Share on other sites More sharing options...
gizmola Posted June 23, 2013 Share Posted June 23, 2013 Either LC_ALL or LC_CTYPE Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1437467 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted June 23, 2013 Author Share Posted June 23, 2013 Well i just tried adding setlocale(LC_ALL, 'fr_FR'); to the top of my PHP file but i'm still getting the same error Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1437582 Share on other sites More sharing options...
xenLiam Posted June 24, 2013 Share Posted June 24, 2013 If you're running it only to show the contents of the zip file, why not make a temporary copy of the zip file with a different file name, you know, with normal alpha-numeric characters, and use that in ZipArchive() and auto-delete it once the contents are shown? Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1437583 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted June 24, 2013 Author Share Posted June 24, 2013 If you're running it only to show the contents of the zip file, why not make a temporary copy of the zip file with a different file name, you know, with normal alpha-numeric characters, and use that in ZipArchive() and auto-delete it once the contents are shown? problem is with the filenames inside the archive, not the filename of the archive. Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1437671 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted June 26, 2013 Author Share Posted June 26, 2013 still stuck here Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1438014 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted June 30, 2013 Author Share Posted June 30, 2013 still stuck here no help ? Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1438598 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted June 30, 2013 Author Share Posted June 30, 2013 I really need to fix this... i'm willing to pay if someone can fix it for me. Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1438654 Share on other sites More sharing options...
jazzman1 Posted July 29, 2013 Share Posted July 29, 2013 (edited) Wow....I saw your urgent post onto the php freelancing section. That one could be very simple with 2-3 lines of code, no more. Just run a unzip linux command through bash with shell_exec in php and display the results on the page. That's all. PS: what happened here? -> http://forums.phpfreaks.com/topic/280579-regexiterator-recursive-iterator-cant-search-file-with-accents/ Edited July 29, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/279401-ziparchive-problem-with-special-characters-in-filenames/#findComment-1442613 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.