Bug #75153 [Nab]: wrap words are getting utf8 error
| From: | patrykmoura at gmail dot com | Date: | Mon, 04 Sep 2017 16:13:31 +0000 |
| Subject: | Bug #75153 [Nab]: wrap words are getting utf8 error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210935@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75153&edit=1
ID: 75153
User updated by: patrykmoura at gmail dot com
Reported by: patrykmoura at gmail dot com
Summary: wrap words are getting utf8 error
Status: Not a bug
Type: Bug
Package: Strings related
Operating System: Unix and Windows
PHP Version: 7.0.23
Block user comment: N
Private report: N
New Comment:
Hi,
I understand the reason for wordwrap, but, why the other ways I've tried, lead me to the same
error?
Previous Comments:
------------------------------------------------------------------------
[2017-09-04 15:57:05] requinix@php.net
As with many string functions wordwrap() is not multibyte safe. Unfortunately the mbstring extension
does not have an equivalent, but the user comments in the docs for wordwrap suggest a couple
PCRE-based solutions for UTF-8 encoding.
------------------------------------------------------------------------
[2017-09-04 14:35:09] patrykmoura at gmail dot com
Description:
------------
Hello,
When I do a wordwrap, or a preg_replace with a regex, or a implode with limit 10 with the word
"Higienização", it returns "Higieniza??ão" instead of
"Higienizaç ão". I guess there's something about the à word.
Thanks
Test script:
---------------
echo wordwrap("Higienização", 10, " ", true);
echo implode(PHP_EOL, str_split("Higienização", 10));
echo preg_replace('/([^\s]{10})(?=[^\s])/', '$1'.' ', $string);
Expected result:
----------------
"Higienizaç ão"
Actual result:
--------------
"Higieniza??ão"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75153&edit=1