5

If I write:

rename('php109.tmp','test.jpg'); 

then it's fine and working.

but if I change it into:

rename('php109.tmp','中文.jpg'); 

it'll report

"No such file or directory...".

But if the multi-byte characters can be written into database then can be read out, then why it fails when it is renamed ?

3
  • does your operating system or filesystem support multi-byte filenames? Commented May 17, 2009 at 3:40
  • yes, and here is more information: it's handled when submitting from web page, page encoding is utf8 db encoding is utf8. and i dumped the string only to find it's also utf8 Commented May 17, 2009 at 3:46
  • What OS are you using? I've tested this on FreeBSD 4.11, Debian 5.0, and OS X 10.6.2, with no errors. If you're using an OS with some sort of syscall trace facility, can you try enabling that? Commented Dec 30, 2009 at 16:26

4 Answers 4

0

File systems do not necessarily use UTF-8. For instance, this is what Wikipedia says about NTFS:

NTFS allows any sequence of 16-bit values for name encoding (file names, stream names, index names, etc.). This means UTF-16 codepoints are supported, but the file system does not check whether a sequence is valid UTF-16 (it allows any sequence of short values, not restricted to those in the Unicode standard).

You might need to use iconv() to convert between charsets.

Sign up to request clarification or add additional context in comments.

Comments

0

Did you try doing a setlocale(LC_ALL, array("es_ES.utf-8","es_ES@euro",'es_ES')); or whatever your country code is, to make sure the locale is set correctly?

If this call does not return something with 'utf-8' in it, it means it failed and will then return the current locale.

Comments

0

This Sample Should Helps , You Should Find Your Language Code Page And Replace With That. I Test Bellow Code And It Works In Windows For Arabic/Persian Names:

$newname = iconv("utf-8", "cp1256","گچپژ"); echo rename("1.txt", $newname); 

Comments

-1

I'm almost sure that the mbstring has nothing to do with this specific problem, I think the problem here relies on the encoding of your .php file.

Try changing the encoding of the file to UTF-8 (no BOM!) in your code editor.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.