From:             josmessa at uk dot ibm dot com
Operating system: Windows XP SP2
PHP version:      5.2CVS-2008-01-31 (snap)
PHP Bug Type:     mbstring related
Bug description:  mb_ereg returns byte length of string instead of character 
length

Description:
------------
When the $regs argument is provided, mb_ereg will return the length of the
matched string. The integer returned though is the byte length of the 
string instead of the character length, which seems illogical for a
multibyte string function.

Reproduce code:
---------------
<?php
mb_regex_encoding('utf-8');
$string_mb =
base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');

$regex = '^.*?[[:blank:]]?[[:punct:][:digit:]]+\.?$';

echo "\nMultibyte String without \$regs arg:\t";
var_dump(mb_ereg($regex, $string_mb));
echo "Multubyte String with \$regs arg:\t";
var_dump(mb_ereg($regex, $string_mb, $regs_mb));
echo "Character length of matched string:\t";
var_dump(mb_strlen($regs_mb[0], 'utf-8'));
?>

Expected result:
----------------
Multibyte String without $regs arg:     int(1)
Multubyte String with $regs arg:        int(21)
Character length of matched string:     int(21)

Actual result:
--------------
Multibyte String without $regs arg:     int(1)
Multubyte String with $regs arg:        int(53)
Character length of matched string:     int(21)

-- 
Edit bug report at http://bugs.php.net/?id=43995&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43995&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43995&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43995&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43995&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43995&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43995&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43995&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43995&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43995&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43995&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43995&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43995&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43995&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43995&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43995&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43995&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43995&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43995&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43995&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43995&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43995&r=mysqlcfg

Reply via email to