diff --git a/composer.json b/composer.json index 3ec28e0..69c5015 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": ">=7.2", "doctrine/lexer": "^1.2", "doctrine/collections": "^1.6", - "patchwork/utf8": ">=1.3" + "symfony/polyfill-mbstring": "^1.23" }, "require-dev": { "phpunit/phpunit": "^9.5" diff --git a/src/ReverseRegex/Parser/CharacterClass.php b/src/ReverseRegex/Parser/CharacterClass.php index 57f3dc0..5618ffa 100644 --- a/src/ReverseRegex/Parser/CharacterClass.php +++ b/src/ReverseRegex/Parser/CharacterClass.php @@ -5,7 +5,6 @@ use ReverseRegex\Generator\LiteralScope; use ReverseRegex\Lexer; use ReverseRegex\Exception as ParserException; -use Patchwork\Utf8; /** * Parse a character class [0-9][a-z] @@ -108,7 +107,7 @@ public function parse(Scope $head, Scope $set, Lexer $lexer) break; case($normal_lexer->isNextToken(Lexer::T_LITERAL_NUMERIC) || $normal_lexer->isNextToken(Lexer::T_LITERAL_CHAR)) : - $index = (integer)Utf8::ord($normal_lexer->lookahead['value']); + $index = (integer)mb_ord($normal_lexer->lookahead['value']); $head->setLiteral($index,$normal_lexer->lookahead['value']); break; default: @@ -131,15 +130,15 @@ public function parse(Scope $head, Scope $set, Lexer $lexer) public function fillRange(Scope $head,$start,$end) { - $start_index = Utf8::ord($start); - $ending_index = Utf8::ord($end); + $start_index = mb_ord($start); + $ending_index = mb_ord($end); if($ending_index < $start_index ) { throw new ParserException(sprintf('Character class range %s - %s is out of order',$start,$end)); } for($i = $start_index; $i <= $ending_index; $i++) { - $head->setLiteral($i,Utf8::chr($i)); + $head->setLiteral($i,mb_chr($i)); } } diff --git a/src/ReverseRegex/Parser/Unicode.php b/src/ReverseRegex/Parser/Unicode.php index 84445e4..64bfd89 100644 --- a/src/ReverseRegex/Parser/Unicode.php +++ b/src/ReverseRegex/Parser/Unicode.php @@ -4,7 +4,6 @@ use ReverseRegex\Generator\Scope; use ReverseRegex\Lexer; use ReverseRegex\Exception as ParserException; -use Patchwork\Utf8; /** * Parse a unicode sequence e.g \x54 \X{4444} @@ -74,7 +73,7 @@ public function evaluate(Lexer $lexer) $number = trim(implode('',$tokens)); - return Utf8::chr(hexdec($number)); + return mb_chr(hexdec($number)); break; case ($lexer->isNextToken(Lexer::T_SHORT_X)) : @@ -92,7 +91,7 @@ public function evaluate(Lexer $lexer) } $value = trim(implode('',$tokens)); - return Utf8::chr(hexdec($value)); + return mb_chr(hexdec($value)); break; default : throw new ParserException('No Unicode expression to evaluate');