3

PHP cannot handle a a file with Unicode characters: when I vist testSite/главная.php on my browser, it throws this error.

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

Fatal error: Unknown: Failed opening required 'blah/blah/testSite/главнаÑ.php' (include_path='.;C:\xampp\php\pear\') in Unknown on line 0

However testSite/главная.html is fine.

Is there anyway that I can get around this or do I have to use a different programming language that handles Unicode better?

Apache htdocs in folder with unicode name

Community
  • 1
  • 1
Tristanisginger
  • 2,181
  • 4
  • 28
  • 41
  • Using non plain ASCII file names, using space in file names is like asking for troubles. **ALWAYS**. Make yourself a favor and drop your bad habits. – Marcin Orlowski Oct 10 '12 at 10:55
  • I understand but I don't have the option to change the filenames. I gotta work with what I have. – Tristanisginger Oct 10 '12 at 11:25
  • It is not possible. Here is the reason why: http://stackoverflow.com/questions/708017/can-a-php-file-name-or-a-dir-in-its-full-path-have-utf-8-characters/16941794#16941794 – Tristanisginger May 28 '14 at 23:00

5 Answers5

0

Opening a php file with a unicode file name is not a php thing, but depends on the underlying operating system. As long as the OS supports unicode file names, it wil work.

On my debian squeeze this is not a problem at all, and windows 7 (where netbeans runs) creating a file named главная.php is without trouble:

include 'главная.php';

enter image description here

JvdBerg
  • 21,777
  • 8
  • 38
  • 55
0

Seems to me, your webserver uses win-1252 encoding for URIs. Try to set utf-8 in your apache/nginx/whatever config. If unicode names are used in require()/include() context only, you can also convert encoding with iconv()/mb_convert_encoding().

SlyChan
  • 769
  • 4
  • 15
0

Maybe it works:

mb_internal_encoding('UTF-8');
ini_set('default_charset', 'UTF-8');
Mahdi
  • 9,247
  • 9
  • 53
  • 74
0

It is not possible.

Here is the thread explaining why

Can a PHP file name (or a dir in its full path) have UTF-8 characters?

Community
  • 1
  • 1
Tristanisginger
  • 2,181
  • 4
  • 28
  • 41
0

Use "wfio://" in PHP5

https://github.com/kenjiuno/php-wfio

For folder access use fix:

.htaccess:

php_value auto_prepend_file C:/fix.php

fix.php:

$file = $_SERVER['SCRIPT_FILENAME'];
if (!is_readable($file)) {
    $file="wfio://".$file;
                include $file;
                exit;
        }
Vitalicus
  • 1,188
  • 13
  • 15