Bug #77777 [Opn->Fbk]: str_word_count function for Chinese text

From: Date: Thu, 21 Mar 2019 05:01:38 +0000
Subject: Bug #77777 [Opn->Fbk]: str_word_count function for Chinese text
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220107@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77777&edit=1 ID: 77777 Updated by: requinix@php.net Reported by: deng5765 at gmail dot com Summary: str_word_count function for Chinese text -Status: Open +Status: Feedback Type: Bug Package: Strings related Operating System: CentOS and MacOS PHP Version: 7.3.3 Block user comment: N Private report: N New Comment: > Counts the number of words inside string. > For the purpose of this function, 'word' is defined as a locale dependent string > containing alphabetic characters, > which also may contain, but not start with "'" and "-" characters. What is your locale set to? Previous Comments: ------------------------------------------------------------------------ [2019-03-21 04:52:22] deng5765 at gmail dot com Description: ------------ Different behaviour of str_word_count function in different operating system(CentOS and MacOS) for Chinese text. It return 0 for pure Chinese text under CentOS. I tested PHP 7.1 and PHP 7.2, same issue. Seems can't find any clue in doc. Test script: --------------- <?php $content = '我不是鱼测试'; echo 'PHP OS: ', PHP_OS, "\n"; echo 'PHP Version: ', PHP_VERSION, "\n"; echo 'Word Count: ', str_word_count($content), "\n"; Expected result: ---------------- PHP OS: Darwin PHP Version: 7.3.3 Word Count: 6 PHP OS: Linux PHP Version: 7.3.3 Word Count: 6 Actual result: -------------- PHP OS: Darwin PHP Version: 7.3.3 Word Count: 6 PHP OS: Linux PHP Version: 7.3.3 Word Count: 0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77777&edit=1

« previous php.bugs (#220107) next »