Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/polyfill-iconv/Iconv.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
125 private static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4); | 125 private static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4); |
126 private static $isValidUtf8; | 126 private static $isValidUtf8; |
127 | 127 |
128 public static function iconv($inCharset, $outCharset, $str) | 128 public static function iconv($inCharset, $outCharset, $str) |
129 { | 129 { |
130 if ('' === $str .= '') { | 130 $str = (string) $str; |
131 if ('' === $str) { | |
131 return ''; | 132 return ''; |
132 } | 133 } |
133 | 134 |
134 // Prepare for //IGNORE and //TRANSLIT | 135 // Prepare for //IGNORE and //TRANSLIT |
135 | 136 |
143 } | 144 } |
144 if ('' === $inCharset) { | 145 if ('' === $inCharset) { |
145 $inCharset = 'iso-8859-1'; | 146 $inCharset = 'iso-8859-1'; |
146 } | 147 } |
147 | 148 |
148 if ('//translit' === substr($outCharset, -10)) { | 149 do { |
149 $translit = '//TRANSLIT'; | 150 $loop = false; |
150 $outCharset = substr($outCharset, 0, -10); | 151 |
151 } | 152 if ('//translit' === substr($outCharset, -10)) { |
152 | 153 $loop = $translit = true; |
153 if ('//ignore' === substr($outCharset, -8)) { | 154 $outCharset = substr($outCharset, 0, -10); |
154 $ignore = '//IGNORE'; | 155 } |
155 $outCharset = substr($outCharset, 0, -8); | 156 |
156 } | 157 if ('//ignore' === substr($outCharset, -8)) { |
157 | 158 $loop = $ignore = true; |
158 if ('//translit' === substr($inCharset, -10)) { | 159 $outCharset = substr($outCharset, 0, -8); |
159 $inCharset = substr($inCharset, 0, -10); | 160 } |
160 } | 161 } while ($loop); |
161 if ('//ignore' === substr($inCharset, -8)) { | 162 |
162 $inCharset = substr($inCharset, 0, -8); | 163 do { |
163 } | 164 $loop = false; |
165 | |
166 if ('//translit' === substr($inCharset, -10)) { | |
167 $loop = true; | |
168 $inCharset = substr($inCharset, 0, -10); | |
169 } | |
170 | |
171 if ('//ignore' === substr($inCharset, -8)) { | |
172 $loop = true; | |
173 $inCharset = substr($inCharset, 0, -8); | |
174 } | |
175 } while ($loop); | |
164 | 176 |
165 if (isset(self::$alias[ $inCharset])) { | 177 if (isset(self::$alias[ $inCharset])) { |
166 $inCharset = self::$alias[ $inCharset]; | 178 $inCharset = self::$alias[ $inCharset]; |
167 } | 179 } |
168 if (isset(self::$alias[$outCharset])) { | 180 if (isset(self::$alias[$outCharset])) { |
519 $encoding = null; | 531 $encoding = null; |
520 } elseif (false === $s = self::iconv($encoding, 'utf-8', $s)) { | 532 } elseif (false === $s = self::iconv($encoding, 'utf-8', $s)) { |
521 return false; | 533 return false; |
522 } | 534 } |
523 | 535 |
524 $s .= ''; | 536 $s = (string) $s; |
525 $slen = self::iconv_strlen($s, 'utf-8'); | 537 $slen = self::iconv_strlen($s, 'utf-8'); |
526 $start = (int) $start; | 538 $start = (int) $start; |
527 | 539 |
528 if (0 > $start) { | 540 if (0 > $start) { |
529 $start += $slen; | 541 $start += $slen; |
620 } | 632 } |
621 | 633 |
622 return substr($u, 0, $j); | 634 return substr($u, 0, $j); |
623 } | 635 } |
624 | 636 |
625 private static function mapToUtf8(&$result, $map, $str, $ignore) | 637 private static function mapToUtf8(&$result, array $map, $str, $ignore) |
626 { | 638 { |
627 $len = strlen($str); | 639 $len = strlen($str); |
628 for ($i = 0; $i < $len; ++$i) { | 640 for ($i = 0; $i < $len; ++$i) { |
629 if (isset($str[$i + 1], $map[$str[$i].$str[$i + 1]])) { | 641 if (isset($str[$i + 1], $map[$str[$i].$str[$i + 1]])) { |
630 $result .= $map[$str[$i].$str[++$i]]; | 642 $result .= $map[$str[$i].$str[++$i]]; |
638 } | 650 } |
639 | 651 |
640 return true; | 652 return true; |
641 } | 653 } |
642 | 654 |
643 private static function mapFromUtf8(&$result, $map, $str, $ignore, $translit) | 655 private static function mapFromUtf8(&$result, array $map, $str, $ignore, $translit) |
644 { | 656 { |
645 $ulenMask = self::$ulenMask; | 657 $ulenMask = self::$ulenMask; |
646 $valid = self::$isValidUtf8; | 658 $valid = self::$isValidUtf8; |
647 | 659 |
648 if ($translit && !self::$translitMap) { | 660 if ($translit && !self::$translitMap) { |
694 } | 706 } |
695 | 707 |
696 return true; | 708 return true; |
697 } | 709 } |
698 | 710 |
699 private static function qpByteCallback($m) | 711 private static function qpByteCallback(array $m) |
700 { | 712 { |
701 return '='.strtoupper(dechex(ord($m[0]))); | 713 return '='.strtoupper(dechex(ord($m[0]))); |
702 } | 714 } |
703 | 715 |
704 private static function pregOffset($offset) | 716 private static function pregOffset($offset) |