note 88128 rejected from function.preg-match by danbrown
| From: | danbrown@php.net | Date: | Mon, 12 Jan 2009 16:26:51 +0000 |
| Subject: | note 88128 rejected from function.preg-match by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149099@lists.php.net to get a copy of this message | ||
Note Submitter: onge
----
There is an problem with PREG_OFFSET_CAPTURE flag and multibyte strings - it return number of bytes,
rather than number of characters. So, if you want to use it for example to truncate text around
found expression using mb_substr, you cant use offset number (because mb_substr DOES count
characters, not bytes).
With use of standard substr it seems it works, but sometimes it "slice multibyte character in
middle", so you get invalid character displayed.
I havent found sufficient solution yet.