dnaber/string-theory

Objective multi-byte string handling

Installs: 451

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 1

pkg:composer/dnaber/string-theory

1.0.0-alpha 2016-03-05 15:29 UTC

This package is auto-updated.

Last update: 2025-09-24 06:48:40 UTC


README

Objective multi-byte string handling in PHP.

public API

StringTheory\Type\StringType

The basic string interface.

StringTheory\Type\MbString

Implementation of StringType for multi-byte strings. Default encoding is set to UTF-8.

Example:

use StringTheory\Type;

$string = new Type\MbString( '苍天有' );

echo $string[ 0 ]; // 苍
echo $string[ 2 ]; // 有 
var_dump( isset( $string[ 3 ] ) ); // false

StringTheory\Model\Scanner

Basic scanner interface that allows a character sequential iteration of a string.

StringTheory\Model\MbScanner

Implementation of the Scanner interface for multi-byte strings. Default encoding is set to UTF-8.

Example:

use StringTheory\Model;

$scanner = new Model\MbScanner( 'abc' );

echo $scanner->current(); // a

$scanner->next();
$scanner->next();
echo $scanner->current(); // c

$scanner->previous();
echo $scanner->current(); // b