Resources
2 years ago
Iconv.php
3 months ago
LICENSE
2 years ago
README.md
4 years ago
bootstrap.php
8 months ago
bootstrap80.php
8 months ago
bootstrap80.php
128 lines
| 1 | <?php |
| 2 | |
| 3 | namespace { |
| 4 | /* |
| 5 | * This file is part of the Symfony package. |
| 6 | * |
| 7 | * (c) Fabien Potencier <fabien@symfony.com> |
| 8 | * |
| 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | * file that was distributed with this source code. |
| 11 | */ |
| 12 | use Symfony\Polyfill\Iconv as p; |
| 13 | if (!\defined('ICONV_IMPL')) { |
| 14 | \define('ICONV_IMPL', 'Symfony'); |
| 15 | } |
| 16 | if (!\defined('ICONV_VERSION')) { |
| 17 | \define('ICONV_VERSION', '1.0'); |
| 18 | } |
| 19 | if (!\defined('ICONV_MIME_DECODE_STRICT')) { |
| 20 | \define('ICONV_MIME_DECODE_STRICT', 1); |
| 21 | } |
| 22 | if (!\defined('ICONV_MIME_DECODE_CONTINUE_ON_ERROR')) { |
| 23 | \define('ICONV_MIME_DECODE_CONTINUE_ON_ERROR', 2); |
| 24 | } |
| 25 | if (!\function_exists('iconv')) { |
| 26 | function iconv(?string $from_encoding, ?string $to_encoding, ?string $string) : string|false |
| 27 | { |
| 28 | return p\Iconv::iconv((string) $from_encoding, (string) $to_encoding, (string) $string); |
| 29 | } |
| 30 | } |
| 31 | if (!\function_exists('iconv_get_encoding')) { |
| 32 | function iconv_get_encoding(?string $type = 'all') : array|string|false |
| 33 | { |
| 34 | return p\Iconv::iconv_get_encoding((string) $type); |
| 35 | } |
| 36 | } |
| 37 | if (!\function_exists('iconv_set_encoding')) { |
| 38 | function iconv_set_encoding(?string $type, ?string $encoding) : bool |
| 39 | { |
| 40 | return p\Iconv::iconv_set_encoding((string) $type, (string) $encoding); |
| 41 | } |
| 42 | } |
| 43 | if (!\function_exists('iconv_mime_encode')) { |
| 44 | function iconv_mime_encode(?string $field_name, ?string $field_value, ?array $options = []) : string|false |
| 45 | { |
| 46 | return p\Iconv::iconv_mime_encode((string) $field_name, (string) $field_value, (array) $options); |
| 47 | } |
| 48 | } |
| 49 | if (!\function_exists('iconv_mime_decode_headers')) { |
| 50 | function iconv_mime_decode_headers(?string $headers, ?int $mode = 0, ?string $encoding = null) : array|false |
| 51 | { |
| 52 | return p\Iconv::iconv_mime_decode_headers((string) $headers, (int) $mode, $encoding); |
| 53 | } |
| 54 | } |
| 55 | if (\extension_loaded('mbstring')) { |
| 56 | if (!\function_exists('iconv_strlen')) { |
| 57 | function iconv_strlen(?string $string, ?string $encoding = null) : int|false |
| 58 | { |
| 59 | null === $encoding && ($encoding = p\Iconv::$internalEncoding); |
| 60 | return \mb_strlen((string) $string, $encoding); |
| 61 | } |
| 62 | } |
| 63 | if (!\function_exists('iconv_strpos')) { |
| 64 | function iconv_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null) : int|false |
| 65 | { |
| 66 | null === $encoding && ($encoding = p\Iconv::$internalEncoding); |
| 67 | return \mb_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); |
| 68 | } |
| 69 | } |
| 70 | if (!\function_exists('iconv_strrpos')) { |
| 71 | function iconv_strrpos(?string $haystack, ?string $needle, ?string $encoding = null) : int|false |
| 72 | { |
| 73 | null === $encoding && ($encoding = p\Iconv::$internalEncoding); |
| 74 | return \mb_strrpos((string) $haystack, (string) $needle, 0, $encoding); |
| 75 | } |
| 76 | } |
| 77 | if (!\function_exists('iconv_substr')) { |
| 78 | function iconv_substr(?string $string, ?int $offset, ?int $length = null, ?string $encoding = null) : string|false |
| 79 | { |
| 80 | null === $encoding && ($encoding = p\Iconv::$internalEncoding); |
| 81 | return \mb_substr((string) $string, (int) $offset, $length, $encoding); |
| 82 | } |
| 83 | } |
| 84 | if (!\function_exists('iconv_mime_decode')) { |
| 85 | function iconv_mime_decode($string, $mode = 0, $encoding = null) |
| 86 | { |
| 87 | $currentMbEncoding = \mb_internal_encoding(); |
| 88 | null === $encoding && ($encoding = p\Iconv::$internalEncoding); |
| 89 | \mb_internal_encoding($encoding); |
| 90 | $decoded = \mb_decode_mimeheader($string); |
| 91 | \mb_internal_encoding($currentMbEncoding); |
| 92 | return $decoded; |
| 93 | } |
| 94 | } |
| 95 | } else { |
| 96 | if (!\function_exists('iconv_strlen')) { |
| 97 | function iconv_strlen(?string $string, ?string $encoding = null) : int|false |
| 98 | { |
| 99 | return p\Iconv::iconv_strlen((string) $string, $encoding); |
| 100 | } |
| 101 | } |
| 102 | if (!\function_exists('iconv_strpos')) { |
| 103 | function iconv_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null) : int|false |
| 104 | { |
| 105 | return p\Iconv::iconv_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); |
| 106 | } |
| 107 | } |
| 108 | if (!\function_exists('iconv_strrpos')) { |
| 109 | function iconv_strrpos(?string $haystack, ?string $needle, ?string $encoding = null) : int|false |
| 110 | { |
| 111 | return p\Iconv::iconv_strrpos((string) $haystack, (string) $needle, $encoding); |
| 112 | } |
| 113 | } |
| 114 | if (!\function_exists('iconv_substr')) { |
| 115 | function iconv_substr(?string $string, ?int $offset, ?int $length = null, ?string $encoding = null) : string|false |
| 116 | { |
| 117 | return p\Iconv::iconv_substr((string) $string, (string) $offset, $length, $encoding); |
| 118 | } |
| 119 | } |
| 120 | if (!\function_exists('iconv_mime_decode')) { |
| 121 | function iconv_mime_decode(?string $string, ?int $mode = 0, ?string $encoding = null) : string|false |
| 122 | { |
| 123 | return p\Iconv::iconv_mime_decode((string) $string, (int) $mode, $encoding); |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 |