From 907d5472d5eca6698491203648f35c43981b59ab Mon Sep 17 00:00:00 2001 From: Philippe Meunier Date: Wed, 16 Feb 2022 11:08:16 -0500 Subject: [PATCH] - Fix deprecated errors for php 8.1 compatibility --- src/ForceUTF8/Encoding.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ForceUTF8/Encoding.php b/src/ForceUTF8/Encoding.php index 2031592..0377035 100644 --- a/src/ForceUTF8/Encoding.php +++ b/src/ForceUTF8/Encoding.php @@ -203,7 +203,7 @@ static function toUTF8($text){ $buf .= $c1 . $c2; $i++; } else { //not valid UTF8. Convert it. - $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc1 = (chr(intdiv(ord($c1), 64)) | "\xc0"); $cc2 = ($c1 & "\x3f") | "\x80"; $buf .= $cc1 . $cc2; } @@ -212,7 +212,7 @@ static function toUTF8($text){ $buf .= $c1 . $c2 . $c3; $i = $i + 2; } else { //not valid UTF8. Convert it. - $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc1 = (chr(intdiv(ord($c1), 64)) | "\xc0"); $cc2 = ($c1 & "\x3f") | "\x80"; $buf .= $cc1 . $cc2; } @@ -221,12 +221,12 @@ static function toUTF8($text){ $buf .= $c1 . $c2 . $c3 . $c4; $i = $i + 3; } else { //not valid UTF8. Convert it. - $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc1 = (chr(intdiv(ord($c1), 64)) | "\xc0"); $cc2 = ($c1 & "\x3f") | "\x80"; $buf .= $cc1 . $cc2; } } else { //doesn't look like UTF8, but should be converted - $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc1 = (chr(intdiv(ord($c1), 64)) | "\xc0"); $cc2 = (($c1 & "\x3f") | "\x80"); $buf .= $cc1 . $cc2; } @@ -234,7 +234,7 @@ static function toUTF8($text){ if(isset(self::$win1252ToUtf8[ord($c1)])) { //found in Windows-1252 special cases $buf .= self::$win1252ToUtf8[ord($c1)]; } else { - $cc1 = (chr(ord($c1) / 64) | "\xc0"); + $cc1 = (chr(intdiv(ord($c1), 64)) | "\xc0"); $cc2 = (($c1 & "\x3f") | "\x80"); $buf .= $cc1 . $cc2; }