|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60918 Buggy grapheme_substr()
Submitted: 2012-01-28 14:10 UTC Modified: 2012-01-29 09:41 UTC
From: nicolas dot grekas+php at gmail dot com Assigned:
Status: Closed Package: intl (PECL)
PHP Version: 5.3.9 OS:
Private report: No CVE-ID: None
 [2012-01-28 14:10 UTC] nicolas dot grekas+php at gmail dot com
See test script.

Test script:

var_export(grapheme_substr('deja', 1, -1));
var_export(grapheme_substr('déjà', 1, -1));

var_export(grapheme_substr('deja', 1, 5));
var_export(grapheme_substr('déjà', 1, 5));

Expected result:


Actual result:



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-29 01:57 UTC]
-Status: Open +Status: Feedback
 [2012-01-29 01:57 UTC]
I was unable to reproduce this. Note that the documentation states that the 
input string must be valid UTF-8. I suspect you are feeding it non-UTF-8.

Try copying and pasting your example script from this web page (which is UTF-8). 
When I did that, my output was:

 [2012-01-29 09:41 UTC] nicolas dot grekas+php at gmail dot com
-Status: Feedback +Status: Closed
 [2012-01-29 09:41 UTC] nicolas dot grekas+php at gmail dot com
You are right, I messed up UTF-8.
What I was experimenting is under PHP5.3.6-ubuntu
Before reporting I tested under 5.3.9, but forgot to properly encode in UTF-8...
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Oct 01 13:01:24 2023 UTC