{"id":17191655,"url":"https://github.com/fab2s/strings","last_synced_at":"2025-04-13T20:07:26.719Z","repository":{"id":56980947,"uuid":"202311421","full_name":"fab2s/Strings","owner":"fab2s","description":"A purely static String Helper to handle more advanced utf8 string manipulations","archived":false,"fork":false,"pushed_at":"2022-09-27T18:41:54.000Z","size":16,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T05:36:43.469Z","etag":null,"topics":["helper","php","simple","string","string-manipulation","utf-8"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fab2s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-14T08:48:49.000Z","updated_at":"2022-11-20T17:35:51.000Z","dependencies_parsed_at":"2022-08-21T11:20:33.356Z","dependency_job_id":null,"html_url":"https://github.com/fab2s/Strings","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fab2s%2FStrings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fab2s%2FStrings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fab2s%2FStrings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fab2s%2FStrings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fab2s","download_url":"https://codeload.github.com/fab2s/Strings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248774988,"owners_count":21159534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["helper","php","simple","string","string-manipulation","utf-8"],"created_at":"2024-10-15T01:26:59.467Z","updated_at":"2025-04-13T20:07:26.688Z","avatar_url":"https://github.com/fab2s.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Strings\n\n[![Build Status](https://travis-ci.com/fab2s/Strings.svg?branch=master)](https://travis-ci.com/fab2s/Strings) [![Total Downloads](https://poser.pugx.org/fab2s/strings/downloads)](//packagist.org/packages/fab2s/strings) [![Monthly Downloads](https://poser.pugx.org/fab2s/strings/d/monthly)](//packagist.org/packages/fab2s/strings) [![Latest Stable Version](https://poser.pugx.org/fab2s/strings/v/stable)](https://packagist.org/packages/fab2s/strings) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/fab2s/strings/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/fab2s/Strings/?branch=master) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com) [![License](https://poser.pugx.org/fab2s/strings/license)](https://packagist.org/packages/fab2s/strings)\n\nA purely static String Helper to handle more advanced utf8 string manipulations\n\n## Installation\n\n`Strings` can be installed using composer:\n\n```\ncomposer require \"fab2s/strings\"\n```\n\n`Strings` is also included in [OpinHelper](https://github.com/fab2s/OpinHelpers) 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\n\nShould you need to work with php bellow 7.1, you can still use [OpinHelper](https://github.com/fab2s/OpinHelpers) `0.x`\n\n## Prerequisites\n\nAs it requires `Utf8`, `Strings` requires [mb_string](https://php.net/mb_string), [ext-intl](https://php.net/intl) is auto detected and used when available for UTF-8 Normalization\n\n## In practice\n\n`Strings` implement some basic text manipulation function that can be pretty useful IRL\n\n\n- `filter(string $string):string` \n\n    Drops Zero Width white chars, normalizes EOL and Normalize UTF8 if [ext-intl](https://php.net/intl) is available\n\n- `singleWsIze(string $string, bool $normalize = false, bool $includeTabs = true):string` \n\n    Replace repeated white-spaces to a single one, preserve original white-spaces unless normalized (every white-spaces to ' '), with or without tabs (\\t)\n\n- `singleLineIze(string $string):string` \n\n    Make string fit in one line by replacing EOLs and white-spaces to normalized single white-spaces\n\n- `dropZwWs(string $string):string` \n\n    Remove Zero Width white-spaces \n\n- `normalizeWs(string $string, bool $includeTabs = true, int $maxConsecutive = null):string` \n\n    Normalize white-spaces to a single ` ` by default, include tabs by default\n\n- `normalizeEol($string, $maxConsecutive = null, $eol = self::EOL):string` \n\n    Normalize EOLs to a single LF by default\n\n- `normalizeText(string $text):string` \n\n    Return `trim`'d and `filter`'d $text \n\n- `normalizeTitle(string $title):string` \n\n    Return `singleLineIze`'d, `normalizeWs`'d, `normalizeText`'d and `ucfirst`'d $title (`\" the best ever \\t\\r\\n article\"` -\u003e `\"The best ever article\"`) \n\n- `normalizeName(string $name):string` \n\n    Return `ucword`'d and `normalizeTitle`'d $name (`\"john \\n\\t doe  \"` -\u003e `\"John Doe\"`) \n\n- `escape(string $string, int $flag = ENT_COMPAT, bool $hardEscape = true):string` \n\n    [htmlspecialchars()](https://php.net/htmlspecialchars) wrapper with UTF8 set as encoding\n\n- `softEscape(string $string, int $flag = ENT_COMPAT):string` \n\n    Shortcut for `escape(string $string, $flag, true)`\n\n- `unEscape(string $string, int $quoteStyle = ENT_COMPAT):string` \n\n    [htmlspecialchars_decode()](https://php.net/htmlspecialchars_decode) wrapper \n\n- `convert(string $string, string $from = null, string $to = self::ENCODING):string` \n\n    Convert encoding to UTF8 by default. Basic $from encoding detection using `Strings::detectEncoding()`\n\n- `detectEncoding(string $string):string|null` \n\n    Detect encoding by checking `Utf8::isUf8()`, then trying with BOMs and ultimately fall back to [mb_detect_encoding()](https://php.net/mb_detect_encoding) with limited charsets first, then more internally in [mb_convert_encoding()](https://php.net/mb_convert_encoding) \n\n- `secureCompare(string $test, string $reference):bool` \n\n    Perform a [Timing Attack](https://en.wikipedia.org/wiki/Timing_attack) safe string comparison (Truly constant operations comparison)\n\n- `contentHash(string $content):string` \n\n    Return a `sha256` hash of the $content prefixed with $content length. Indented to quickly and reliably detect $content updates.\n\n## Requirements\n\n`Strings` is tested against php 7.2, 7.3, 7.4 and 8.0\n\n## Contributing\n\nContributions are welcome, do not hesitate to open issues and submit pull requests.\n\n## License\n\n`Strings` is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffab2s%2Fstrings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffab2s%2Fstrings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffab2s%2Fstrings/lists"}