mpyw / base-utf8
BaseXX encoder/decoder those support any valid UTF-8 sequences.
Installs: 40
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/mpyw/base-utf8
Requires
- php: >=5.3.2
- lib-pcre: *
This package is auto-updated.
Last update: 2025-09-25 03:57:53 UTC
README
BaseXX encoder/decoder which support any valid UTF-8 sequences.
Installation
composer require mpyw/base-utf8
Features
Pass your character set as the first argument for the constructor.
Default value is ABCD...WXYZabcd...wxyz0123456789+/
(Base64).
- It must be either array or string.
- The number of elements must be a power of two. (2, 4, 8, 16, 32, 64, ...)
- Any paddings such as
=
are not appended. - Control characters
\x00-\x20
are ignored.
Example
require __DIR__ . '/vendor/autoload.php'; use Mpyw\BaseUTF8\Coder; $coder = new Coder; // Base64 echo $coder->encode('foobar') . PHP_EOL; // Zm9vYmFy echo $coder->decode('Zm9vYmFy') . PHP_EOL; // foobar echo $coder->decode("Z m \n9v Y\tmFy") . PHP_EOL; // foobar $coder = new Coder('ABCDabcd'); // Base8 echo $coder->encode('foobar') . PHP_EOL; // DBacdbbdDAacAbcC echo $coder->decode('DBacdbbdDAacAbcC') . PHP_EOL; // foobar $coder = new Coder('ンアッーイキソ!'); // UTF-8 Base8 echo $coder->encode('田所浩二') . PHP_EOL; echo $coder->decode('!ア!アッッソン!アキンイソンン!アキーッソキア!アアーキッアイ') . PHP_EOL;