jfcherng/php-mb-string
High-performance multibyte string class for PHP. Stores text internally as UTF-32 for fast, safe random read/write, replace, insert, and substring operations on long UTF-8 strings—avoiding the repeated decoding overhead of frequent mb_* calls.
A high performance multibyte sting implementation for frequently reading/writing operations.
Consider that you have a LONG multibyte string and you want to do lots of following operations on it.
$char = $str[5]; or $str[5] = '許';.str_replace($search, $replace, $str);.substr_replace($insert, $str, $position, 0);.substr($str, $start, $length);.Because strings in PHP are not UTF-8, to do operations above safely,
you have to either use mb_*() functions or calculate the index by yourself.
Using mb_*() functions frequently can be a performance loss because it has
to re-decode the source string basing on the given encoding every time when you call it.
The longer the string is, the severer the problem becomes.
Instead, this class internally stores the string in its UTF-32 form,
which is fixed-width (1 char always occupies 4 bytes) so we are able to
perform speedy random accesses. With the power of random access, we could
use str_*() functions to do the job internally.
composer require jfcherng/php-mb-string
I develop this for a PHP diff package, jfcherng/php-diff.
How can I help you explore Laravel packages today?