#28899 [Opn->Asn]: mb_substr() and substr() work differently
| From: | sniper@php.net | Date: | Wed, 21 Dec 2005 22:21:16 +0000 |
| Subject: | #28899 [Opn->Asn]: mb_substr() and substr() work differently | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-90848@lists.php.net to get a copy of this message | ||
ID: 28899
Updated by: sniper@php.net
Reported By: mauroi at digbang dot com
-Status: Open
+Status: Assigned
Bug Type: mbstring related
Operating System: *
PHP Version: 5CVS, 4CVS (2004-12-12)
-Assigned To:
+Assigned To: hirokawa
New Comment:
Rui, can you check this please? Seems a bit odd that mbstring
overloaded substr() works differently from the PHP core substr()..
Previous Comments:
------------------------------------------------------------------------
[2005-02-23 16:56:34] drraf at tlen dot pl
If mb_string() can overload substr() (when function overloading in on
when using mbstring) - in my opinion mb_substr() should be fixed.
------------------------------------------------------------------------
[2005-02-03 03:25:48] sniper@php.net
Whatever is the "logical" behaviour of the function, it doesn't really
matter: We will NOT change the behaviour of substr() at this point.
Thus the only place to change is mbstring.
------------------------------------------------------------------------
[2004-12-20 13:58:20] mauroi at digbang dot com
just to mention it... lot of code written with the mb_* function
overload relies on substr returning a zero length string... changing
substr to work like mb_substr won't break anything (i think)
------------------------------------------------------------------------
[2004-12-20 10:28:55] moriyoshi@php.net
The very nature of "substr" is that the function returns
the specified part of the string whenever the range is
valid and returns an error status if it is out of range.
If a null string is a valid string entity, then it
should be able to be referred to by index "0" and thus
the implementation returns a null string instead of
false. Or you would say this isn't really logical? :)
------------------------------------------------------------------------
[2004-12-15 04:19:11] sniper@php.net
The correct quote from up-to-date manual:
"If string is less than or equal to start characters long, FALSE will
be returned."
Notice the 'or equal' there?
Thus logically mb_substr() is buggy.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/28899
--
Edit this bug report at http://bugs.php.net/?id=28899&edit=1