bootstrap.php 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 (extension_loaded('iconv')) {
  12. return;
  13. }
  14. if (\PHP_VERSION_ID >= 80000) {
  15. return require __DIR__.'/bootstrap80.php';
  16. }
  17. if (!defined('ICONV_IMPL')) {
  18. define('ICONV_IMPL', 'Symfony');
  19. }
  20. if (!defined('ICONV_VERSION')) {
  21. define('ICONV_VERSION', '1.0');
  22. }
  23. if (!defined('ICONV_MIME_DECODE_STRICT')) {
  24. define('ICONV_MIME_DECODE_STRICT', 1);
  25. }
  26. if (!defined('ICONV_MIME_DECODE_CONTINUE_ON_ERROR')) {
  27. define('ICONV_MIME_DECODE_CONTINUE_ON_ERROR', 2);
  28. }
  29. if (!function_exists('iconv')) {
  30. function iconv($from_encoding, $to_encoding, $string) { return p\Iconv::iconv($from_encoding, $to_encoding, $string); }
  31. }
  32. if (!function_exists('iconv_get_encoding')) {
  33. function iconv_get_encoding($type = 'all') { return p\Iconv::iconv_get_encoding($type); }
  34. }
  35. if (!function_exists('iconv_set_encoding')) {
  36. function iconv_set_encoding($type, $encoding) { return p\Iconv::iconv_set_encoding($type, $encoding); }
  37. }
  38. if (!function_exists('iconv_mime_encode')) {
  39. function iconv_mime_encode($field_name, $field_value, $options = []) { return p\Iconv::iconv_mime_encode($field_name, $field_value, $options); }
  40. }
  41. if (!function_exists('iconv_mime_decode_headers')) {
  42. function iconv_mime_decode_headers($headers, $mode = 0, $encoding = null) { return p\Iconv::iconv_mime_decode_headers($headers, $mode, $encoding); }
  43. }
  44. if (extension_loaded('mbstring')) {
  45. if (!function_exists('iconv_strlen')) {
  46. function iconv_strlen($string, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strlen($string, $encoding); }
  47. }
  48. if (!function_exists('iconv_strpos')) {
  49. function iconv_strpos($haystack, $needle, $offset = 0, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strpos($haystack, $needle, $offset, $encoding); }
  50. }
  51. if (!function_exists('iconv_strrpos')) {
  52. function iconv_strrpos($haystack, $needle, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strrpos($haystack, $needle, 0, $encoding); }
  53. }
  54. if (!function_exists('iconv_substr')) {
  55. function iconv_substr($string, $offset, $length = 2147483647, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_substr($string, $offset, $length, $encoding); }
  56. }
  57. if (!function_exists('iconv_mime_decode')) {
  58. 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; }
  59. }
  60. } else {
  61. if (!function_exists('iconv_strlen')) {
  62. if (extension_loaded('xml')) {
  63. function iconv_strlen($string, $encoding = null) { return p\Iconv::strlen1($string, $encoding); }
  64. } else {
  65. function iconv_strlen($string, $encoding = null) { return p\Iconv::strlen2($string, $encoding); }
  66. }
  67. }
  68. if (!function_exists('iconv_strpos')) {
  69. function iconv_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Iconv::iconv_strpos($haystack, $needle, $offset, $encoding); }
  70. }
  71. if (!function_exists('iconv_strrpos')) {
  72. function iconv_strrpos($haystack, $needle, $encoding = null) { return p\Iconv::iconv_strrpos($haystack, $needle, $encoding); }
  73. }
  74. if (!function_exists('iconv_substr')) {
  75. function iconv_substr($string, $offset, $length = 2147483647, $encoding = null) { return p\Iconv::iconv_substr($string, $offset, $length, $encoding); }
  76. }
  77. if (!function_exists('iconv_mime_decode')) {
  78. function iconv_mime_decode($string, $mode = 0, $encoding = null) { return p\Iconv::iconv_mime_decode($string, $mode, $encoding); }
  79. }
  80. }