#30195 [Com]: scandir etc cannot read Chinese file/folder name
| From: | missingno at ifrance dot com | Date: | Sat, 31 Mar 2007 23:30:06 +0000 |
| Subject: | #30195 [Com]: scandir etc cannot read Chinese file/folder name | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-110985@lists.php.net to get a copy of this message | ||
ID: 30195
Comment by: missingno at ifrance dot com
Reported By: percy at savant dot us
Status: No Feedback
Bug Type: *Directory/Filesystem functions
Operating System: windows xp/2003
PHP Version: 5CVS-2004-09-22 (dev)
New Comment:
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...
Previous Comments:
------------------------------------------------------------------------
[2006-07-10 10:02:31] gandhavallakiran at yahoo dot co dot in
hi i have used the babel class in my coding of php. but it could not
read the characters of china and japan i.e. special characters. it is
displaying the blank space instead of china or japan text. could you
help me in this reacord how to display china characters in php. please
it is very urgent kindly help me.
------------------------------------------------------------------------
[2005-02-25 01:00:07] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2005-02-17 15:22:16] moriyoshi@php.net
Note that all of these are PHP code, so paste it within
<?php ?>.
------------------------------------------------------------------------
[2005-02-17 15:20:57] moriyoshi@php.net
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');
------------------------------------------------------------------------
[2005-01-28 18:02:07] moleary at preg dot org
This is also the case for Japanese characters on the Windows platform.
A note in the PHP manual says that opendir() uses ISO 8859-1 by default
on WIndows installations.
REPRO:
1) Install East Asian language supprto to XP through the Regioanl
languages control panel
2) add a file with Japanese characters as the name (I copied a couple
strings from the asahi.com web site)
ACTUAL:
1) These same characters as text will be presented properly with the
proper code page and/or header encoding.
2) The characters are not correctly parsed when looping through the
contents of an opendir() on the directory in which you placed the file
you created under the repro steps.
EXPECTED:
Ability to define charset for opendir(), or at very least use a more
standard UTF-8 instead of ISO 8859-1 so that Asian named files can have
their proper names returned by opendir()
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/30195
--
Edit this bug report at http://bugs.php.net/?id=30195&edit=1