|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51919 $str[] unexpected result with multibyte character
Submitted: 2010-05-26 11:53 UTC Modified: 2010-05-26 11:55 UTC
From: msluis at sellvation dot nl Assigned:
Status: Not a bug Package: Strings related
PHP Version: Irrelevant OS: WinXP, Linux Debian
Private report: No CVE-ID: None
 [2010-05-26 11:53 UTC] msluis at sellvation dot nl
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

Test script:

    $sStr = "André";



Expected result:
string(6) "André" 
string(1) "é"

Actual result:
string(6) "André" 
string(1) "�"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-26 11:55 UTC]
-Status: Open +Status: Bogus
 [2010-05-26 11:55 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP has no idea about"characters"just bytes.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 12:01:29 2024 UTC