Bug #77777 [Com]: str_word_count function for Chinese text

From: Date: Thu, 21 Mar 2019 05:55:41 +0000
Subject: Bug #77777 [Com]: str_word_count function for Chinese text
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220108@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 Comment by: deng5765 at gmail dot com Reported by: deng5765 at gmail dot com Summary: str_word_count function for Chinese text 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: Ah, sorry, didn't notice that part. Mac: LANG= LC_COLLATE="C" LC_CTYPE="UTF-8" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL= CentOS: LANG=en_US.utf-8 LC_CTYPE="en_US.utf-8" LC_NUMERIC="en_US.utf-8" LC_TIME="en_US.utf-8" LC_COLLATE="en_US.utf-8" LC_MONETARY="en_US.utf-8" LC_MESSAGES="en_US.utf-8" LC_PAPER="en_US.utf-8" LC_NAME="en_US.utf-8" LC_ADDRESS="en_US.utf-8" LC_TELEPHONE="en_US.utf-8" LC_MEASUREMENT="en_US.utf-8" LC_IDENTIFICATION="en_US.utf-8" LC_ALL=en_US.utf-8 Previous Comments: ------------------------------------------------------------------------ [2019-03-21 05:01:37] requinix@php.net > 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? ------------------------------------------------------------------------ [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 (#220108) next »