From a8b86de955ecb9285832e41c7850ac316eb5bd68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Fabr=C3=A9gat?= Date: Fri, 17 Jul 2020 17:47:13 +0200 Subject: [PATCH 1/5] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2b17caf..af34d30 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "codeinc/strip-accents", - "version": "1.0.0", + "version": "1.1.0", "description": "Removes accents from strings", "homepage": "https://github.com/CodeIncHQ/StripAccents", "type": "library", From 94d608d9a7d54b872579bb6ce7f923efce6cbba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Fabr=C3=A9gat?= Date: Fri, 17 Jul 2020 17:53:00 +0200 Subject: [PATCH 2/5] contact infos --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index af34d30..d67e0b4 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ "authors": [ { "name": "Joan Fabrégat", - "email": "joan@codeinc.fr", - "homepage": "https://www.codeinc.fr", + "email": "joan@codeinc.co", + "homepage": "https://www.codeinc.co", "role": "developer" } ], From e8466af083f05704fc77d23ce13c1a542a7bf8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Fabr=C3=A9gat?= Date: Fri, 17 Jul 2020 17:53:07 +0200 Subject: [PATCH 3/5] stripNonPrint example --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2acf7ac..083d4ca 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ echo StripAccents::strip("C'est une super chaîne de caractères avec beaucoup d echo StripAccents::strip("ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ"); // echoes: AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy +echo StripAccents::stripNonPrint("ABC ÀÈÝ 是我这"); +// echoes: ABC AEY --- + // You can specify any encoding supported by htmlentities() as a second parameter echo StripAccents::strip("A strïng with àccénts", "iso-8859-1"); ``` From 51e2c59690d22f8626ce9faa8effe2e3a287726e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Fabr=C3=A9gat?= Date: Fri, 17 Jul 2020 17:53:17 +0200 Subject: [PATCH 4/5] adds stripNonPrint() --- src/StripAccents.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/StripAccents.php b/src/StripAccents.php index 80bed25..1ffb9a3 100644 --- a/src/StripAccents.php +++ b/src/StripAccents.php @@ -61,4 +61,17 @@ public static function strip(string $string, $encoding = self::DEFAULT_ENCODING) return $string; } + + /** + * @param string $string + * @param string $encoding + * @param string $replaceWith + * @return string + */ + public static function stripNonPrint(string $string, + string $replaceWith = '', + string $encoding = self::DEFAULT_ENCODING): string + { + return preg_replace('/[[:^print:]]/', $replaceWith, self::strip($string, $encoding)); + } } \ No newline at end of file From bc5b39c345e4704f06ca137fadfbf626873ca8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Fabr=C3=A9gat?= Date: Fri, 17 Jul 2020 17:53:26 +0200 Subject: [PATCH 5/5] small fix --- src/StripAccents.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/StripAccents.php b/src/StripAccents.php index 1ffb9a3..220a023 100644 --- a/src/StripAccents.php +++ b/src/StripAccents.php @@ -39,7 +39,7 @@ class StripAccents * @param string $encoding * @return string */ - public static function strip(string $string, $encoding = self::DEFAULT_ENCODING):string + public static function strip(string $string, string $encoding = self::DEFAULT_ENCODING): string { // converting accents in HTML entities $string = htmlentities($string, ENT_NOQUOTES, $encoding);