2017 © Pedro Peláez
 

library php-mb-string

An implementation targeting high performance for frequently reading/writing operations.

image

jfcherng/php-mb-string

An implementation targeting high performance for frequently reading/writing operations.

  • Thursday, July 26, 2018
  • by jfcherng
  • Repository
  • 1 Watchers
  • 0 Stars
  • 443 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

php-mb-string

GitHub Workflow Status (branch) Packagist Packagist Version Project license GitHub stars Donate to this project using Paypal, (*1)

A high performance multibyte sting implementation for frequently reading/writing operations., (*2)

Why I Write This Package?

Consider that you have a LONG multibyte string and you want to do lots of following operations on it., (*3)

  • Random reading/writing such as $char = $str[5]; or $str[5] = '許';.
  • Replacement such as str_replace($search, $replace, $str);.
  • Insertion such as substr_replace($insert, $str, $position, 0);.
  • Get substring such as 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., (*4)

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., (*5)

Installation

composer require jfcherng/php-mb-string

Example

See tests/MbStringTest.php., (*6)

Benchmark

See benchmark/_results.txt., (*7)

What Are You Doing With This Package?

I develop this for a PHP diff package, jfcherng/php-diff., (*8)

The Versions

26/07 2018

dev-master

9999999-dev

An implementation targeting high performance for frequently reading/writing operations.

  Sources   Download

MIT

The Requires

  • php ^7.1.3
  • ext-iconv *

 

The Development Requires

by Jack Cherng

18/07 2018

1.2.3

1.2.3.0

An implementation targeting high performance for frequently reading/writing operations.

  Sources   Download

MIT

The Requires

  • php ^7.1.3
  • ext-iconv *

 

The Development Requires

by Jack Cherng

04/07 2018

1.2.2

1.2.2.0

An implementation targeting high performance for frequently reading/writing operations.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng

04/07 2018

1.2.1

1.2.1.0

An implementation targeting high performance for frequently reading/writing operations.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng

25/06 2018

1.2.0

1.2.0.0

An implementation targeting high performance for frequently reading/writing operations.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng

25/06 2018

1.1.0

1.1.0.0

An implementation targeting high performance for frequently reading/writing operations.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng

24/06 2018

1.0.0

1.0.0.0

An implementation targeting high performance for frequently reading/writing operations.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng