Bug #74958 [NEW]: ScanDir Have Problem with UTF8 Character in Linux

From: Date: Thu, 20 Jul 2017 21:04:03 +0000
Subject: Bug #74958 [NEW]: ScanDir Have Problem with UTF8 Character in Linux
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210154@lists.php.net to get a copy of this message
From:             global dot ninety at gmail dot com
Operating system: Linux
PHP version:      7.1.7
Package:          *General Issues
Bug Type:         Bug
Bug description:ScanDir Have Problem with UTF8 Character in Linux

Description:
------------
scandir Have Problem with UTF8 Character

Please check this image:
http://i.imgur.com/3K2Y9YZ.jpg

my folders and files name is UTF8 character (Farsi).

i need scan directorys for get list files with ScanDir , but this
function have problem with UTF8 name.

Tested Information: (i have linux host in HostUpon)
System: Linux cs11.uhcloud.com 2.6.32-673.8.1.lve1.4.3.el6.x86_64 #1 SMP
Wed Feb 10 08:57:30 EST 2016 x86_64 
PHP Version: 7.1.7

Test script:
---------------
$files = scanDirectories('files');
print_r($files);

public static function scanDirectories($rootDir, $allData=array()) {
        $invisibleFileNames = array(".", "..");
        $dirContent = scandir($rootDir);
        foreach($dirContent as $key => $content) {
            $path = $rootDir.'/'.$content;
            if(!in_array($content, $invisibleFileNames)) {
                if(Self::isFile($path)) {
                    $allData[] = $path;
                }elseif(Self::isDir($path)) {
                    $allData = Self::scanDirectories($path, $allData);
                }
            }
        }
        return $allData;
    }

    public static function isDir($path)
    {
        $result = pathinfo($path);
        if (!array_key_exists("extension",$result))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public static function isFile($path)
    {
        $result = pathinfo($path);
        if (array_key_exists("extension",$result))
        {
            return true;
        }
        else
        {
            return false;
        }
    }


-- 
Edit bug report at https://bugs.php.net/bug.php?id=74958&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=74958&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=74958&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=74958&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=74958&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=74958&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=74958&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=74958&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=74958&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=74958&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=74958&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=74958&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=74958&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=74958&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74958&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=74958&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=74958&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=74958&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74958&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=74958&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=74958&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#210154) next »