fab2s / bom
Purely static zero dependencies BOM Helper to handle unicode BOMs
Installs: 237 491
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.1|^8.0
Requires (Dev)
- phpunit/phpunit: ~7.0|~8.0
This package is auto-updated.
Last update: 2024-12-16 17:30:22 UTC
README
A purely static zero dependencies byte Order Mark Helper to handle unicode BOMs
Installation
Bom
can be installed using composer:
composer require "fab2s/bom"
Bom
is also included in OpinHelper which packages several bellow "Swiss Army Knife" level Helpers covering some of the most annoying aspects of php programing, such as UTF8 string manipulation, high precision Mathematics or properly locking a file
Should you need to work with php bellow 7.1, you can still use OpinHelper 0.x
Prerequisites
Bom
has no specific dependencies
In practice
Bom
supports UTF-8|16|32
BOMs in both Little and Big Endianness
Bom
is minimalistic, it only exposes five methods
// get Bom $bomAtStartOfString = Bom::extract($string); // returns null when none are found // remove eventual BOM from beging of string $bomLessString = Bom::drop($string); // get encoding from a supported BOM $encoding = Bom::getBomEncoding($bom); // returns null if the BOM is not valid // get BOM for a supported encoding $bom = Bom::getEncodingBom($encoding); // returns null if the encoding is not supported (has no BOM) // get the list of BOMs as an array with corresponding encodings as indexes $boms = Bom::getBoms(); // returns an associatiove array of encodings and correesponding BOMs foreach ($boms as $encoding => $bom) { // do something ... }
Requirements
Bom
is tested against php 7.1, 7.2, 7.3, 7.4 and 8.0
Contributing
Contributions are welcome, do not hesitate to open issues and submit pull requests.
License
Bom
is open-sourced software licensed under the MIT license.