diff options
Diffstat (limited to 'vendor/symfony/polyfill-php72/Php72.php')
| -rw-r--r-- | vendor/symfony/polyfill-php72/Php72.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/vendor/symfony/polyfill-php72/Php72.php b/vendor/symfony/polyfill-php72/Php72.php new file mode 100644 index 0000000000..dee935e7e2 --- /dev/null +++ b/vendor/symfony/polyfill-php72/Php72.php @@ -0,0 +1,73 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Polyfill\Php72; + +/** + * @author Nicolas Grekas <p@tchwork.com> + * + * @internal + */ +final class Php72 +{ + public static function stream_isatty($stream) + { + return function_exists('posix_isatty') && @posix_isatty($stream); + } + + public static function sapi_windows_vt100_support() + { + return false; + } + + public static function utf8_encode($s) + { + $s .= $s; + $len = strlen($s); + + for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) { + switch (true) { + case $s[$i] < "\x80": $s[$j] = $s[$i]; break; + case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break; + default: $s[$j] = "\xC3"; $s[++$j] = chr(ord($s[$i]) - 64); break; + } + } + + return substr($s, 0, $j); + } + + public static function utf8_decode($s) + { + $s .= ''; + $len = strlen($s); + + for ($i = 0, $j = 0; $i < $len; ++$i, ++$j) { + switch ($s[$i] & "\xF0") { + case "\xC0": + case "\xD0": + $c = (ord($s[$i] & "\x1F") << 6) | ord($s[++$i] & "\x3F"); + $s[$j] = $c < 256 ? chr($c) : '?'; + break; + + case "\xF0": ++$i; + case "\xE0": + $s[$j] = '?'; + $i += 2; + break; + + default: + $s[$j] = $s[$i]; + } + } + + return substr($s, 0, $j); + } +} |
