|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2004-09-22 17:05 UTC] percy at savant dot us
 Description: ------------ By using the opendir and readdir or scandir can only read English file/folder name; unrecognised code for Chinese File and folder name. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 09:00:01 2025 UTC | 
You might have shown strings of a native encoding as UTF-8 in your browser, most likely because of wrong Content-Type. Try putting one of the following at the top of your script and let's see what'll happen: CP936 (Simplified Chinese): header('Content-Type', 'text/html; charset=GB2312'); CP949 (Korean): header('Content-Type', 'text/html; charset=EUC-KR'); CP950 (Traditional Chinese): header('Content-Type', 'text/html; charset=BIG5'); CP932 (Japanese): header('Content-Type', 'text/html; charset=Shift_JIS');Same problem here. On WinXP with PHP 5.2.0, using iso-8859-1 as charset for the system (though the filesystem uses utf-8 for folders/files names). I need to access folders whose names are encoded using UTF-8. readdir/scandir won't allow me to do so (returning '?' for characters outside the system charset). The page is served like this: header('Content-Type: text/html; charset=utf-8'); So the browser really isn't at fault. Serving the document with a more specific charset is not an option since I have to display texts in many different languages on the page. As moleary at preg dot org suggested, it would be really nice to have an option to force PHP to use a certain encoding while accessing the filesystem. Or maybe, make it so that it uses the same encoding as the filesystem instead of defaulting to iso-8859-1...Hi, have the same problem and my solution is: using mb_convert_encoding. $open = opendir($path); foreach( $open as $value ) { $value = mb_convert_encoding($value, mb_detect_order($value), "UTF-8"); } If saving file to folder using urlencode. To view using urldecode.