Bug #80360 [Com]: Unicode character property \p{L} truncates match

From: Date: Fri, 13 Nov 2020 13:37:32 +0000
Subject: Bug #80360 [Com]: Unicode character property \p{L} truncates match
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230325@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80360&edit=1 ID: 80360 Comment by: benjamin dot morel at gmail dot com Reported by: benjamin dot morel at gmail dot com Summary: Unicode character property \p{L} truncates match Status: Open Type: Bug Package: PCRE related Operating System: Ubuntu 18 PHP Version: 7.4.12 Block user comment: N Private report: N New Comment: Actually, "déjà" should be considered a single word with \p{L}, so the expected result should be: 566f696cc3a02064c3a96ac3a0 true 566f696cc3a0 true 64c3a96ac3a0 true Previous Comments: ------------------------------------------------------------------------ [2020-11-13 13:34:37] benjamin dot morel at gmail dot com Description: ------------ When using \p{L} on accented letters, the resulting match is truncated and therefore invalid UTF-8. Examples: à = C3A0 is returned as C3 é = C3A9 is returned as C3 Test script: --------------- $str = 'Voilà déjà'; display($str); preg_match_all('/\p{L}+/', $str, $matches); foreach ($matches[0] as $match) { display($match); } function display($str) { echo bin2hex($str), ' '; var_export(mb_check_encoding($str, 'UTF-8')); echo PHP_EOL; } Expected result: ---------------- 566f696cc3a02064c3a96ac3a0 true 566f696cc3a0 true 64c3a9 true 6ac3a0 true Actual result: -------------- 566f696cc3a02064c3a96ac3a0 true 566f696cc3 false 64c3 false 6ac3 false ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80360&edit=1

« previous php.bugs (#230325) next »