Buggy grapheme_substr() on edge case
| Bug #62759 | Buggy grapheme_substr() on edge case | ||||
|---|---|---|---|---|---|
| Submitted: | 2012-08-06 16:05 UTC | Modified: | - | ||
| From: | okin7 at yahoo dot fr | Assigned: | |||
| Status: | Closed | Package: | *Languages/Translation | ||
| PHP Version: | 5.4.5 | OS: | |||
| Private report: | No | CVE-ID: | None | ||
[2012-08-06 16:05 UTC] okin7 at yahoo dot fr
Description:
------------
See test script below.
The strangest behavior is the difference between a pure ASCII string and an UTF-8 with chars in the [80-FFFF] range.
The other wrong thing is the difference of behavior between substr() and grapheme_substr(). I think substr's behavior is the good one.
Test script:
---------------
<?php
var_dump(substr('deja', 1, -4));
var_dump(substr('deja', -1, 0));
var_dump(grapheme_substr('deja', 1, -4));
var_dump(grapheme_substr('deja', -1, 0));
var_dump(grapheme_substr('déjà', 1, -4));
var_dump(grapheme_substr('déjà', -1, 0));
?>
Expected result:
----------------
bool(false)
string(0) ""
bool(false)
string(0) ""
bool(false)
string(0) ""
Actual result:
--------------
bool(false)
string(0) ""
bool(false)
string(0) ""
string(5) "éjà"
bool(false)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2013-06-24 04:27 UTC] stas@php.net
-Status: Open +Status: Closed