Bug #77239 [Com]: pathinfo strips umlauts only at the beginning

From: Date: Tue, 05 Feb 2019 13:53:07 +0000
Subject: Bug #77239 [Com]: pathinfo strips umlauts only at the beginning
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219366@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77239&edit=1

 ID:                 77239
 Comment by:         alex dot a dot pott at gmail dot com
 Reported by:        stephan dot eicher at check24 dot de
 Summary:            pathinfo strips umlauts only at the beginning
 Status:             Open
 Type:               Bug
 Package:            *Directory/Filesystem functions
 Operating System:   Linux
 PHP Version:        7.1.24
 Block user comment: N
 Private report:     N

 New Comment:

This problem seems to be OS dependent. If I run the following script I get different results.
Locally I'm running on MacOS Mojave use homebrew for PHP 7.2.

Test script:
---------------
<?php
setlocale(LC_ALL, 'C');
var_dump(pathinfo('Ö Ü Å Ø äöüåøhello.txt'));


Output using docker:
---------------
docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp
php:7.2-cli php test-locale-pathinfo.php
array(4) {
  ["dirname"]=>
  string(1) "."
  ["basename"]=>
  string(29) " Ü Å Ø äöüåøhello.txt"
  ["extension"]=>
  string(3) "txt"
  ["filename"]=>
  string(25) " Ü Å Ø äöüåøhello"
}

Output locally:
---------------
php test-locale-pathinfo.php                                                                
array(4) {
  ["dirname"]=>
  string(1) "."
  ["basename"]=>
  string(31) "Ö Ü Å Ø äöüåøhello.txt"
  ["extension"]=>
  string(3) "txt"
  ["filename"]=>
  string(27) "Ö Ü Å Ø äöüåøhello"
}


Previous Comments:
------------------------------------------------------------------------
[2018-12-04 19:32:07] stephan dot eicher at check24 dot de

Description:
------------
Pathinfo will strip umlauts from the filename beginning if locale is not correct set.

The strange thing is that it will not strip other umlauts for example if they are in the middle of
the string.

I would expect that it strips all umlauts or none but not that it will strip them from the beginning
but not in the string.

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

setlocale(LC_ALL, 'C');

echo pathinfo('änderungs', PATHINFO_FILENAME) . PHP_EOL;

echo pathinfo('bestandübertragung', PATHINFO_FILENAME) . PHP_EOL;

Expected result:
----------------
änderungs
bestandübertragung


Actual result:
--------------
nderungs
bestandübertragung


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=77239&edit=1


Thread (2 messages)

« previous php.bugs (#219366) next »