#49939 [NEW]: iconv_substr, incorrect behaviour with $length=0
| From: | ladislav at marek dot su | Date: | Wed, 21 Oct 2009 08:32:58 +0000 |
| Subject: | #49939 [NEW]: iconv_substr, incorrect behaviour with $length=0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-143748@lists.php.net to get a copy of this message | ||
From: ladislav at marek dot su
Operating system: linux
PHP version: 5.3.0
PHP Bug Type: ICONV related
Bug description: iconv_substr, incorrect behaviour with $length=0
Description:
------------
According to documentation and reflection: iconv_substr has third argument
$length, default value is 0, but iconv_substr returns different result when
argument is not passed and when argument is passed as zero. (Now it's not
possible to call iconv_substr with $charset argument and preserve correct
behaviour.)
Reproduce code:
---------------
var_dump(iconv_substr('foobar', 3)); // "bar"
var_dump(iconv_substr('foobar', 3, 0)); // ""
var_dump(iconv_substr('foobar', 3, NULL, 'UTF-8')); // ""
Expected result:
----------------
string(3) "bar"
string(0) "bar"
string(0) "bar"
Actual result:
--------------
string(3) "bar"
string(0) ""
string(0) ""
--
Edit bug report at http://bugs.php.net/?id=49939&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49939&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49939&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49939&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=49939&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49939&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=49939&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=49939&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=49939&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=49939&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=49939&r=support
Expected behavior: http://bugs.php.net/fix.php?id=49939&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=49939&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=49939&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=49939&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49939&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49939&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=49939&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=49939&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=49939&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=49939&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=49939&r=mysqlcfg