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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nicolas dot grekas+php at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Tue Dec 03 11:01:29 2024 UTC