php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
6 + 20 = ?
Subscribe to this entry?

 
 [2012-01-28 14:10 UTC] nicolas dot grekas+php at gmail dot com
Description:
------------
See test script.

Test script:
---------------
<?php

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:
----------------
"ej"
"éj"

"eja"
"éjà"

Actual result:
--------------
"ej"
false

"eja"
false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-29 01:57 UTC] rasmus@php.net
-Status: Open +Status: Feedback
 [2012-01-29 01:57 UTC] rasmus@php.net
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:

'ej'
'éj'
'eja'
'éjà'
 [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 http://bugs.php.net/55562 under PHP5.3.6-ubuntu
Before reporting I tested under 5.3.9, but forgot to properly encode in UTF-8...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 08:01:28 2024 UTC