php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15706 readdir doesn't return correct FRENCH filenames
Submitted: 2002-02-24 23:39 UTC Modified: 2002-08-17 01:03 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: musallam at sympatico dot ca Assigned:
Status: Closed Package: Directory function related
PHP Version: 4.1.1 OS: WIN XP
Private report: No CVE-ID: None
 [2002-02-24 23:39 UTC] musallam at sympatico dot ca
hi,
I'm think this is a valid bug :)
I'm trying to list files from a certain directory with readdir() but any accented capital letter is returned without the accent... I'll explain:

----------------------------------
my directory listing is:
. 
.. 
Bloqueurs des canaux calciques voltage.doc 
Diur?tiques.doc 
REGF et JNK.pdf 
?icosanoides.doc     <--------
----------------------------------

the file pointed by the arrow is returned "Eicosanoides.doc" no accent on the capital E.
The problem isn't present with lowercase letters, i.e. the filename "Diur?tiques.doc" is returned correctly.

here's my code:

    $handle=opendir($dir);
    echo "Files:<br>\n";
    while (false !== ($file = readdir($handle))) { 
        echo "<br>$file\n";
    }
    closedir($handle); 

I hope this is enough info, dont hesitate to email me for anything. I'm running Apache1.3.23 with PHP4.1.1 binaries from php.net


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-25 06:15 UTC] sander@php.net
I don't think this is a PHP problem...
 [2002-02-25 17:50 UTC] musallam at sympatico dot ca
I'm not sure either, but fact remains, the letters returned have either a wrong encoding or wrong string conversion...
 [2002-07-14 10:46 UTC] nohn@php.net
On the Web you should always use 7-Bit ASCII (no german umlauts or these daft french characters or whatever is no "standard")
 [2002-07-14 17:54 UTC] sniper@php.net
Does this happen if you run the same code fragment
on command line?

 [2002-08-05 08:29 UTC] sfox@php.net
I just spent some days playing with this one before coming to the conclusion that it's not a PHP bug *as such*, more to do with MS character types not being ANSI-compatible.  The PHP directory functions for win32 use MS functions which return MS-defined char types (as opposed to the PHP string functions, which don't touch MS and which work fine :).  We use those to set up win32 directory functions in a way that is as nearly as possible compatible with unix-flavoured systems, and the returned char type is then used throughout the universal directory functions.

Unfortunately 'char' in this instance means 'single byte'.

Fixing the win32 dir functions within PHP to make it possible for other MS char types to be used would mean that the wrong type is returned to the PHP directory functions used by all systems.  It appears that the only way to internationalise PHP in this area would be to separate out the win32 directory functions completely ..

I'm not happy with the politics of this, particularly given the widespread use of dir and file names within PHP source (think of streams, etc).  If anyone can think of a better way to implement dirent for win32, please do!
 [2002-08-06 19:39 UTC] sfox@php.net
OK, for full strangeness try doing that readdir() with the current CVS version of PHP.  Suddenly this week it started working on XP as it should (but not on win9x or ME, where it shouldn't, due to the aforementioned single byte char encoding).

I'm still waiting to get test results from people with NT/w2k too, but if it works there I'm closing this bug report, as there's no way to differentiate between different flavours of Windows.  Probably marked 'magic worked here'... although actually I suspect that Rui fixed it in 4.2 and something overrode that fix in the interim.

Feedback would be useful at this point :)


 [2002-08-17 01:03 UTC] sfox@php.net
No feedback and the thing works now on XP at least, so I'm closing this bug down.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Mar 07 00:01:23 2021 UTC