php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40962 dirname faild in UTF8 dirname + Source Code
Submitted: 2007-03-30 18:40 UTC Modified: 2007-04-02 21:15 UTC
From: lamsoft at gmail dot com Assigned:
Status: Not a bug Package: *Unicode Issues
PHP Version: 5.2.1 OS: WinXP SP2
Private report: No CVE-ID: None
 [2007-03-30 18:40 UTC] lamsoft at gmail dot com
Description:
------------
unlink, rename function cannot be executed if the filename is in unicode character, but opendir, readdir work fine.

The following output is from the browser which the encoding is already set to UTF-8, it still some of the character cannot be read.

The OS is English, but the regional settings has been set to Chinese (Taiwan), so that the PHP can only read characters those are in English Character or BIG5.

<b>Warning</b>:  unlink(h:\ndsrom\temp\unzipped/EZ [WWW.ABCDE.ORG] - [?&#65533;&#65533;,&#65533;&#65533;?&#65533;&#65533;,ROM,??,&#65533;&#65533;?,?&#65533;bEZ].url.url) [<a href='function.unlink'>function.unlink</a>]: Invalid argument in <b>D:\HTTP\Sub\nds\cli\php\checkUpdate_3.php</b> on line <b>157</b><br />

<br />
<b>Warning</b>:  unlink(h:\ndsrom\temp\unzipped/&#65533;&#997;&#65533;?&#65533;&#65533;.txt) [<a href='function.unlink'>function.unlink</a>]: Invalid argument in <b>D:\HTTP\Sub\nds\cli\php\checkUpdate_3.php</b> on line <b>157</b><br />
<br />
<b>Warning</b>:  rename(h:\ndsrom\temp\unzipped/&#65533;&#65533;?&#65533;&#65533;&#65533;?DS &#65533;&#65533;??&#65533;P&#65533;&#65533;b&#65533;P&#65533;&#65533;?&#65533;&#65533;.nds,h:\ndsrom\temp\unzipped/test.zip) [<a href='function.rename'>function.rename</a>]: Invalid argument in <b>D:\HTTP\Sub\nds\cli\php\checkUpdate_3.php</b> on line <b>161</b><br />

Directory listing works fine, but it can't show the character~~
Array
(
    [0] => h:\ndsrom\temp\unzipped/EZ [WWW.EMU-ZONE.ORG] - [?&#65533;&#65533;,&#65533;&#65533;?&#65533;&#65533;,ROM,??,&#65533;&#65533;?,?&#65533;bEZ].url.url
    [1] => h:\ndsrom\temp\unzipped/&#65533;&#997;&#65533;?&#65533;&#65533;.txt
    [2] => h:\ndsrom\temp\unzipped/&#65533;&#65533;?&#65533;&#65533;&#65533;?DS &#65533;&#65533;??&#65533;P&#65533;&#65533;b&#65533;P&#65533;&#65533;?&#65533;&#65533;.nds
)

The file contains in that folder which browsed by Explorer: (An image, those filename are some Simplified Chinese name in UTF8 encoding)
http://xs313.xs.to/xs313/07135/34tsdg.jpg

Reproduce code:
---------------
it is included in the description.
In addition, the parameter in the rename and unlink is passed by the function of "directoryToArray" which is copied from "http://snippets.dzone.com/posts/show/155" and use foreach to unlink or rename the filename

Expected result:
----------------
The file can be renamed and unlink successfully without any warnings.


Actual result:
--------------
it is included in the description.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-30 18:43 UTC] lamsoft at gmail dot com
Since the browser also cannot submit the special character, here is the snapshot of the error message.

http://xs313.xs.to/xs313/07135/list.jpg
 [2007-04-02 21:15 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The file operations do not support unicode.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Feb 24 06:01:26 2020 UTC