Bug #62759 [Opn->Csd]: Buggy grapheme_substr() on edge case

From: Date: Mon, 24 Jun 2013 04:27:14 +0000
Subject: Bug #62759 [Opn->Csd]: Buggy grapheme_substr() on edge case
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-179734@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62759&edit=1

 ID:                 62759
 Updated by:         stas@php.net
 Reported by:        okin7 at yahoo dot fr
 Summary:            Buggy grapheme_substr() on edge case
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            *Languages/Translation
 PHP Version:        5.4.5
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=860a5c4b01cd63588ed2eaae76cf0243ca8c3173
Log: Fix bug #62759: Buggy grapheme_substr() on edge case


Previous Comments:
------------------------------------------------------------------------
[2012-08-06 16:05:52] 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)



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62759&edit=1


Thread (2 messages)

« previous php.bugs (#179734) next »