Bug #51919 [NEW]: $str[] unexpected result with multibyte character
From:
Operating system: WinXP, Linux Debian
PHP version: Irrelevant
Package: Strings related
Bug Type: Bug
Bug description:$str[] unexpected result with multibyte character
Description:
------------
When you access a multibyte character in an UTF-8 encoded string using
array
brackets [] it only returns the first byte instead of the full character.
WindowsXP SP3 PHP 5.3.0
WindowsXP SP3 PHP 5.3.2
Linux Debian PHP 5.2.6-1+lenny8
Linux Debian PHP 5.3.2-0.dotdeb.2
PHP Ini settings:
default_charset = "utf-8"
mbstring.internal_encoding = UTF-8
mbstring.func_overload = 7
http://us.php.net/manual/en/language.types.string.php#language.types.string.substr
Test script:
---------------
<?php
$sStr = "André";
var_dump($sStr);
var_dump($sStr[4]);
?>
Expected result:
----------------
string(6) "André"
string(1) "é"
Actual result:
--------------
string(6) "André"
string(1) "�"
--
Edit bug report at http://bugs.php.net/bug.php?id=51919&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51919&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51919&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=51919&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=51919&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51919&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51919&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51919&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51919&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51919&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51919&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51919&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51919&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51919&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51919&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51919&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51919&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51919&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51919&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51919&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51919&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51919&r=mysqlcfg
Thread (2 messages)
- msluis at sellvation dot nl