|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55562 grapheme_substr() returns false if length parameter is to large
Submitted: 2011-09-01 13:19 UTC Modified: 2011-09-04 18:50 UTC
From: thomas at weinert dot info Assigned: stas (profile)
Status: Closed Package: I18N and L10N related
PHP Version: 5.3.8 OS: Windows
Private report: No CVE-ID: None
 [2011-09-01 13:19 UTC] thomas at weinert dot info
If the input string contains multibyte characters and the length argument is greater then the possible maximum length of the result the function returns false.

Test script:
  grapheme_substr('FOK', 1, 20), // expected: OK
  grapheme_substr('한국어', 1, 20) //expected: 국어

Expected result:
string(2) "OK"
string(6) "국어"

Actual result:
string(2) "OK"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-04 17:14 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: stas
 [2011-09-04 17:14 UTC]
I can confirm this bug, but I'm not sure how to fix it correctly. If I fix the 
related logic, the substr tests then partially fail. This function is cryptic and 
should really deserve some comments about what means each variable name and what 
are their goals...
 [2011-09-04 18:49 UTC]
Automatic comment from SVN on behalf of stas
Log: fix bug 55562 - make substr always return rest of the string if length is too long
 [2011-09-04 18:50 UTC]
-Status: Assigned +Status: Closed
 [2011-09-04 18:50 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

fixed, thanks
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Feb 23 18:01:28 2024 UTC