bootstrap80.php 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. use Symfony\Polyfill\Iconv as p;
  11. if (!defined('ICONV_IMPL')) {
  12. define('ICONV_IMPL', 'Symfony');
  13. }
  14. if (!defined('ICONV_VERSION')) {
  15. define('ICONV_VERSION', '1.0');
  16. }
  17. if (!defined('ICONV_MIME_DECODE_STRICT')) {
  18. define('ICONV_MIME_DECODE_STRICT', 1);
  19. }
  20. if (!defined('ICONV_MIME_DECODE_CONTINUE_ON_ERROR')) {
  21. define('ICONV_MIME_DECODE_CONTINUE_ON_ERROR', 2);
  22. }
  23. if (!function_exists('iconv')) {
  24. function iconv(?string $from_encoding, ?string $to_encoding, ?string $string): string|false { return p\Iconv::iconv((string) $from_encoding, (string) $to_encoding, (string) $string); }
  25. }
  26. if (!function_exists('iconv_get_encoding')) {
  27. function iconv_get_encoding(?string $type = 'all'): array|string|false { return p\Iconv::iconv_get_encoding((string) $type); }
  28. }
  29. if (!function_exists('iconv_set_encoding')) {
  30. function iconv_set_encoding(?string $type, ?string $encoding): bool { return p\Iconv::iconv_set_encoding((string) $type, (string) $encoding); }
  31. }
  32. if (!function_exists('iconv_mime_encode')) {
  33. function iconv_mime_encode(?string $field_name, ?string $field_value, ?array $options = []): string|false { return p\Iconv::iconv_mime_encode((string) $field_name, (string) $field_value, (array) $options); }
  34. }
  35. if (!function_exists('iconv_mime_decode_headers')) {
  36. function iconv_mime_decode_headers(?string $headers, ?int $mode = 0, ?string $encoding = null): array|false { return p\Iconv::iconv_mime_decode_headers((string) $headers, (int) $mode, $encoding); }
  37. }
  38. if (extension_loaded('mbstring')) {
  39. if (!function_exists('iconv_strlen')) {
  40. function iconv_strlen(?string $string, ?string $encoding = null): int|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strlen((string) $string, $encoding); }
  41. }
  42. if (!function_exists('iconv_strpos')) {
  43. function iconv_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
  44. }
  45. if (!function_exists('iconv_strrpos')) {
  46. function iconv_strrpos(?string $haystack, ?string $needle, ?string $encoding = null): int|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strrpos((string) $haystack, (string) $needle, 0, $encoding); }
  47. }
  48. if (!function_exists('iconv_substr')) {
  49. function iconv_substr(?string $string, ?int $offset, ?int $length = null, ?string $encoding = null): string|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_substr((string) $string, (int) $offset, $length, $encoding); }
  50. }
  51. if (!function_exists('iconv_mime_decode')) {
  52. function iconv_mime_decode($string, $mode = 0, $encoding = null) { $currentMbEncoding = mb_internal_encoding(); null === $encoding && $encoding = p\Iconv::$internalEncoding; mb_internal_encoding($encoding); $decoded = mb_decode_mimeheader($string); mb_internal_encoding($currentMbEncoding); return $decoded; }
  53. }
  54. } else {
  55. if (!function_exists('iconv_strlen')) {
  56. if (extension_loaded('xml')) {
  57. function iconv_strlen(?string $string, ?string $encoding = null): int|false { return p\Iconv::strlen1((string) $string, $encoding); }
  58. } else {
  59. function iconv_strlen(?string $string, ?string $encoding = null): int|false { return p\Iconv::strlen2((string) $string, $encoding); }
  60. }
  61. }
  62. if (!function_exists('iconv_strpos')) {
  63. function iconv_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Iconv::iconv_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
  64. }
  65. if (!function_exists('iconv_strrpos')) {
  66. function iconv_strrpos(?string $haystack, ?string $needle, ?string $encoding = null): int|false { return p\Iconv::iconv_strrpos((string) $haystack, (string) $needle, $encoding); }
  67. }
  68. if (!function_exists('iconv_substr')) {
  69. function iconv_substr(?string $string, ?int $offset, ?int $length = null, ?string $encoding = null): string|false { return p\Iconv::iconv_substr((string) $string, (string) $offset, $length, $encoding); }
  70. }
  71. if (!function_exists('iconv_mime_decode')) {
  72. function iconv_mime_decode(?string $string, ?int $mode = 0, ?string $encoding = null): string|false { return p\Iconv::iconv_mime_decode((string) $string, (int) $mode, $encoding); }
  73. }
  74. }