PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #37738 basename does not work with Japanese
Submitted:8 Jun 2006 6:09am UTC Modified: 8 Jun 2006 6:37am UTC
From:joey at alegria dot co dot jp Assigned to:
Status:Wont fix Category:*Directory/Filesystem functions
Version:5CVS-2006-06-08 (CVS) OS:Fedora Core 4
Votes:9 Avg. Score:4.7 ± 0.7 Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%) Same OS:1 (16.7%)
View/Vote Developer Edit Submission

Have you experienced this issue?
Rate the importance of this bug to you:

[8 Jun 2006 6:09am UTC] joey at alegria dot co dot jp
Description:
------------
Simply put, basename() does ot work with Japanese filepaths. If the
filename is Japanese only the extension part of the filename is
returned. So a filename "/folder/ファイル名.txt" resolves to just
".txt". I discovered the problem when performing a basename() on the
$_FILES array's 'name' element for uploaded Japanese files, however
after testing the bug occurs no matter how you supply the filename.

My PHP environment is running with UTF-8 internal encoding.

The code snippet below illustrates this perfectly.

Reproduce code:
---------------
<?php
// show normal behavior with roman filename
$filename='/myfolder/roman_filename.txt';
echo "The full filename of the romanized file is $filename.\n"; //
/myfolder/roman_filename.txt
$basename=basename($filename);
echo "The basename of the romanized file is $basename.\n"; //
/roman_filename.txt
// show behavior with Japanese filename
$filename='/myfolder/日本語のファイル名.txt';
echo "The full filename of the Japanese file is $filename.\n"; //
/myfolder/日本語のファイル名.txt
$basename=basename($filename);
echo "The basename of the Japanese file is $basename."; // .txt
?>

Expected result:
----------------
The full filename of the romanized file is
/myfolder/roman_filename.txt.
The basename of the romanized file is roman_filename.txt.
The full filename of the Japanese file is
/myfolder/日本語のファイル名.txt.
The basename of the Japanese file is 日本語のファイル名.txt.

Actual result:
--------------
The full filename of the romanized file is
/myfolder/roman_filename.txt.
The basename of the romanized file is roman_filename.txt.
The full filename of the Japanese file is
/myfolder/日本語のファイル名.txt.
The basename of the Japanese file is .txt.
[8 Jun 2006 6:37am UTC] derick@php.net
Won't fix in PHP 5. This will be implemented for PHP 6.

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC