php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78817 pathinfo() on filenames starting with utf-8 character fails
Submitted: 2019-11-15 10:41 UTC Modified: 2019-11-15 10:51 UTC
From: jasverix at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 7.2.24 OS: Debian Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jasverix at gmail dot com
New email:
PHP Version: OS:

 

 [2019-11-15 10:41 UTC] jasverix at gmail dot com
Description:
------------
We have a filename starting with a non-ASCII filename character like "Æ", "Ø" or "Å". Then we try to get the filename without extension using PATHINFO_FILENAME.

PHP will trim the first character from the resulting string.

Test script:
---------------
<?php

$fileName = 'ÅfileÅnameÅ.docx';

// outputs "fileÅnameÅ" - missing starting character
echo pathinfo($fileName, PATHINFO_FILENAME) . "\n";

Expected result:
----------------
ÅfileÅnameÅ

Actual result:
--------------
fileÅnameÅ

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-15 10:42 UTC] jasverix at gmail dot com
PHP Version:
PHP 7.2.24-1+0~20191026.31+debian10~1.gbpbbacde (cli) (built: Oct 26 2019 14:20:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.24-1+0~20191026.31+debian10~1.gbpbbacde, Copyright (c) 1999-2018, by Zend Technologies
 [2019-11-15 10:51 UTC] sjon@php.net
-Status: Open +Status: Not a bug
 [2019-11-15 10:51 UTC] sjon@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

This is documented - see https://www.php.net/pathinfo

> Caution
> 
> pathinfo() is locale aware, so for it to parse a path containing multibyte characters correctly, the matching locale must be set using the setlocale() function.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 12:01:36 2025 UTC