Bug #79308 [Com]: Unexpected length of unicode string returned

From: Date: Wed, 25 Mar 2020 22:38:17 +0000
Subject: Bug #79308 [Com]: Unexpected length of unicode string returned
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226264@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79308&edit=1

 ID:                 79308
 Comment by:         srl295 at gmail dot com
 Reported by:        dpiekarski at dompie dot de
 Summary:            Unexpected length of unicode string returned
 Status:             Not a bug
 Type:               Bug
 Package:            *Unicode Issues
 Operating System:   Ubuntu 18.04.4 LTS
 PHP Version:        7.4.3
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

This is a User Perceived Character, aka Extended Grapheme Cluster, see http://www.unicode.org/reports/tr29/

स्ते is one cluster. If you use a Unicode-aware (especially GUI)
text editor with the arrow keys through the string नमस्ते , you will
see that the cursor and selection don't break up between the  "m" and the
"ste" 

See for example http://www.unicode.org/reports/tr29/#Table_Sample_Grapheme_Clusters
where "षि" is one grapheme cluster.


So I would say this is not a bug.


Previous Comments:
------------------------------------------------------------------------
[2020-02-26 14:53:46] cmb@php.net

This is not related to the PHP version; e.g. PHP 7.3 with ICU
66.0.1 prints int(3) as well, so it's obviously an upstream issue.

नमस्ते

------------------------------------------------------------------------
[2020-02-26 12:50:25] dpiekarski at dompie dot de

Description:
------------
Getting the grapheme_strlen() of the string 'नमस्ते' returns
3 instead of expecting 4.

ICU version 	65.1
ICU Data version 	65.1
ICU TZData version 	2019c
ICU Unicode version 	12.1 
iconv library version => 2.27

On another system (Debian 10) with PHP7.3 and
ICU version => 63.1
ICU Data version => 63.1
ICU TZData version => 2018e
ICU Unicode version => 11.0
iconv library version => 2.28

it works as expected.


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

$word = 'नमस्ते';
var_dump(grapheme_strlen($word));

Expected result:
----------------
int(4)

Actual result:
--------------
int(3)


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



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


Thread (4 messages)

« previous php.bugs (#226264) next »