PluginProbe ʕ •ᴥ•ʔ
MailPoet – Newsletters, Email Marketing, and Automation / 5.23.1
MailPoet – Newsletters, Email Marketing, and Automation v5.23.1
5.28.1 5.28.0 5.27.0 5.26.0 5.26.1 5.25.0 5.24.0 4.43.0 4.43.1 4.44.0 4.44.1 4.45.0 4.46.0 4.47.0 4.48.0 4.48.1 4.48.2 4.49.0 4.49.1 4.5.0 4.5.1 4.5.2 4.50.0 4.50.1 4.51.0 4.51.1 4.51.2 4.52.0 4.53.0 4.54.0 4.55.0 4.56.0 4.57.0 4.58.0 4.58.1 4.58.2 4.6.0 4.6.1 4.6.2 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 5.0.0 5.0.1 5.0.2 5.1.0 5.1.1 5.10.0 5.10.1 5.11.0 5.12.0 5.12.1 5.12.10 5.12.11 5.12.12 5.12.13 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.12.7 5.12.8 5.12.9 5.13.0 5.13.1 5.13.2 5.14.0 5.14.1 5.14.2 5.14.3 5.15.0 5.15.1 5.16.0 5.16.1 5.16.2 5.16.3 5.16.4 5.17.0 5.17.1 5.17.2 5.17.3 5.17.4 5.17.5 5.17.6 5.18.0 5.19.0 5.2.0 5.2.1 5.2.2 5.2.3 5.20.0 5.21.0 5.21.1 5.21.2 5.21.3 5.22.0 5.22.1 5.22.2 5.22.3 5.22.4 5.23.0 5.23.1 5.23.2 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.7.0 5.7.1 5.8.0 5.8.1 5.9.0 3.0.0-beta.15 3.7.1 3.0.0-beta.16 3.7.2 3.0.0-beta.17 3.7.3 3.0.0-beta.18 3.7.4 3.0.0-beta.19 3.7.5 3.0.0-beta.2 3.7.6 3.0.0-beta.20 3.7.8 3.0.0-beta.21 3.70.0 3.0.0-beta.22 3.71.0 3.0.0-beta.23 3.71.1 3.0.0-beta.23.1 3.71.2 3.0.0-beta.23.2 3.71.3 3.0.0-beta.24 3.72.0 3.0.0-beta.25 3.73.0 3.0.0-beta.26 3.73.1 3.0.0-beta.27 3.73.2 3.0.0-beta.28 3.74.0 3.0.0-beta.29 3.74.1 3.0.0-beta.3 3.74.2 3.0.0-beta.30 3.74.3 3.0.0-beta.31 3.75.0 3.0.0-beta.32 3.75.1 3.0.0-beta.33 3.76.0 3.0.0-beta.33.1 3.77.0 3.0.0-beta.34.0.0 3.77.1 3.0.0-beta.36.0.0 3.78.0 3.0.0-beta.36.0.1 3.79.0 3.0.0-beta.36.2.0 3.8 3.0.0-beta.36.3.0 3.8.1 3.0.0-beta.36.3.1 3.8.2 3.0.0-beta.37.0.0 3.8.3 3.0.0-beta.4 3.8.4 3.0.0-beta.5 3.8.5 3.0.0-beta.6 3.8.6 3.0.0-beta.7 3.80.0 3.0.0-beta.7.1 3.81.0 3.0.0-beta.8 3.82.0 3.0.0-beta.9 3.83.0 3.0.0-rc.1.0.0 3.84.0 3.0.0-rc.1.0.1 3.84.1 3.0.0-rc.1.0.2 3.85.0 3.0.0-rc.1.0.3 3.85.1 3.0.0-rc.1.0.4 3.86.0 3.0.0-rc.2.0.0 3.87.0 3.0.0-rc.2.0.1 3.87.1 3.0.0-rc.2.0.2 3.87.2 3.0.0-rc.2.0.3 3.88.0 3.0.1 3.88.1 3.0.2 3.88.2 3.0.3 3.89.0 3.0.4 3.89.1 3.0.5 3.89.2 3.0.6 3.89.3 3.0.7 3.89.4 3.0.8 3.9.0 3.0.9 3.9.1 3.1.0 3.90.0 3.10 3.90.1 3.10.1 3.90.2 3.100.0 3.91.0 3.100.1 3.91.1 3.100.2 3.92.0 3.101.0 3.92.1 3.101.1 3.93.0 3.102.0 3.93.1 3.102.1 3.94.0 3.103.0 3.95.0 3.103.1 3.95.1 3.11.0 3.96.0 3.11.1 3.96.1 3.11.2 3.97.0 3.11.3 3.98.0 3.11.4 3.98.1 3.11.5 3.99.0 3.12.0 3.99.1 3.12.1 4.0.0 3.13.0 4.0.1 3.14.0 4.1.0 3.14.1 4.1.1 3.15.0 4.10.0 3.16.0 4.11.0 3.16.1 4.11.1 3.16.2 4.12.0 3.16.3 4.12.1 3.17.0 4.12.2 3.17.1 4.13.0 3.17.2 4.14.0 3.18.0 4.15.0 3.18.1 4.16.0 3.18.2 4.17.0 3.19.0 4.17.1 3.19.1 4.18.0 3.19.2 4.18.1 3.19.3 4.19.0 3.2.0 4.2.0 3.2.1 4.20.0 3.2.2 4.20.1 3.2.3 4.20.2 3.2.4 4.21.0 3.2.5 4.22.0 3.20.0 4.22.1 3.21.0 4.22.2 3.21.1 4.23.0 3.22.0 4.24.0 3.23.0 4.25.0 3.23.1 4.26.0 3.23.2 4.26.1 3.24.0 4.27.0 3.25.0 4.28.0 3.25.1 4.29.0 3.26.0 4.3.0 3.26.1 4.3.1 3.27.0 4.30.0 3.28.0 4.31.0 3.29.0 4.31.1 3.3.0 4.32.0 3.3.1 4.33.0 3.3.2 4.34.0 3.3.3 4.35.0 3.3.4 4.35.1 3.3.5 4.36.0 3.3.6 4.37.0 3.30.0 4.38.0 3.31.0 4.39.0 3.31.1 4.4.0 3.32.0 4.40.0 3.32.1 4.41.0 3.32.2 4.41.1 3.33.0 4.41.2 3.34.0 4.41.3 3.34.1 4.42.0 3.34.2 4.42.1 3.34.3 3.34.4 3.35.0 3.35.1 3.35.3 3.35.4 3.36.0 3.37.0 3.37.1 3.37.2 3.37.3 3.38.0 3.38.1 3.39.0 3.39.1 3.39.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.40.0 3.40.1 3.41.0 3.41.1 3.41.2 3.42.0 3.42.1 3.42.2 3.42.3 3.43.0 3.43.1 3.44.0 3.45.0 3.45.1 3.46.0 3.46.1 3.46.10 3.46.11 3.46.12 3.46.13 3.46.14 3.46.2 3.46.3 3.46.4 3.46.5 3.46.6 3.46.7 3.46.8 3.46.9 3.47.0 3.47.1 3.47.10 3.47.11 3.47.2 3.47.3 3.47.5 3.47.6 3.47.7 3.47.9 3.48.0 3.48.1 3.49.0 3.49.1 3.5.0 3.5.1 3.50.0 3.51.0 3.51.1 3.51.2 3.52.0 3.53.0 3.54.0 3.54.1 3.54.2 3.54.3 3.55.0 3.55.1 3.56.0 3.56.1 3.56.2 3.57.0 3.57.1 3.58.0 3.59.0 3.59.1 3.59.2 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.60.0 3.60.1 3.60.10 3.60.11 3.60.12 3.60.2 3.60.3 3.60.4 3.60.6 3.60.7 3.60.8 3.60.9 3.61.0 3.62.0 3.62.1 3.63.0 3.64.0 3.64.1 3.64.2 3.64.3 3.65.0 trunk 3.65.1 3.0.0 3.66.0 3.0.0-beta.1 3.67.0 3.0.0-beta.10 3.67.1 3.0.0-beta.11 3.68.0 3.0.0-beta.12 3.69.0 3.0.0-beta.13 3.69.1 3.0.0-beta.14 3.7.0
mailpoet / vendor-prefixed / symfony / polyfill-mbstring / Mbstring.php
mailpoet / vendor-prefixed / symfony / polyfill-mbstring Last commit date
Resources 1 year ago Mbstring.php 6 months ago bootstrap.php 1 year ago bootstrap80.php 1 year ago index.php 3 years ago
Mbstring.php
692 lines
1 <?php
2 namespace MailPoetVendor\Symfony\Polyfill\Mbstring;
3 if (!defined('ABSPATH')) exit;
4 final class Mbstring
5 {
6 public const MB_CASE_FOLD = \PHP_INT_MAX;
7 private const SIMPLE_CASE_FOLD = [['µ', 'ſ', "�
8 ", 'ς', "ϐ", "ϑ", "ϕ", "ϖ", "ϰ", "ϱ", "ϵ", "", ""], ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "", 'ι']];
9 private static $encodingList = ['ASCII', 'UTF-8'];
10 private static $language = 'neutral';
11 private static $internalEncoding = 'UTF-8';
12 public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
13 {
14 if (\is_array($fromEncoding) || null !== $fromEncoding && \false !== \strpos($fromEncoding, ',')) {
15 $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
16 } else {
17 $fromEncoding = self::getEncoding($fromEncoding);
18 }
19 $toEncoding = self::getEncoding($toEncoding);
20 if ('BASE64' === $fromEncoding) {
21 $s = \base64_decode($s);
22 $fromEncoding = $toEncoding;
23 }
24 if ('BASE64' === $toEncoding) {
25 return \base64_encode($s);
26 }
27 if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
28 if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
29 $fromEncoding = 'Windows-1252';
30 }
31 if ('UTF-8' !== $fromEncoding) {
32 $s = \iconv($fromEncoding, 'UTF-8//IGNORE', $s);
33 }
34 return \preg_replace_callback('/[\\x80-\\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
35 }
36 if ('HTML-ENTITIES' === $fromEncoding) {
37 $s = \html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
38 $fromEncoding = 'UTF-8';
39 }
40 return \iconv($fromEncoding, $toEncoding . '//IGNORE', $s);
41 }
42 public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
43 {
44 $ok = \true;
45 \array_walk_recursive($vars, function (&$v) use(&$ok, $toEncoding, $fromEncoding) {
46 if (\false === ($v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding))) {
47 $ok = \false;
48 }
49 });
50 return $ok ? $fromEncoding : \false;
51 }
52 public static function mb_decode_mimeheader($s)
53 {
54 return \iconv_mime_decode($s, 2, self::$internalEncoding);
55 }
56 public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
57 {
58 \trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
59 }
60 public static function mb_decode_numericentity($s, $convmap, $encoding = null)
61 {
62 if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
63 \trigger_error('mb_decode_numericentity() expects parameter 1 to be string, ' . \gettype($s) . ' given', \E_USER_WARNING);
64 return null;
65 }
66 if (!\is_array($convmap) || 80000 > \PHP_VERSION_ID && !$convmap) {
67 return \false;
68 }
69 if (null !== $encoding && !\is_scalar($encoding)) {
70 \trigger_error('mb_decode_numericentity() expects parameter 3 to be string, ' . \gettype($s) . ' given', \E_USER_WARNING);
71 return '';
72 // Instead of null (cf. mb_encode_numericentity).
73 }
74 $s = (string) $s;
75 if ('' === $s) {
76 return '';
77 }
78 $encoding = self::getEncoding($encoding);
79 if ('UTF-8' === $encoding) {
80 $encoding = null;
81 if (!\preg_match('//u', $s)) {
82 $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
83 }
84 } else {
85 $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
86 }
87 $cnt = \floor(\count($convmap) / 4) * 4;
88 for ($i = 0; $i < $cnt; $i += 4) {
89 // collector_decode_htmlnumericentity ignores $convmap[$i + 3]
90 $convmap[$i] += $convmap[$i + 2];
91 $convmap[$i + 1] += $convmap[$i + 2];
92 }
93 $s = \preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use($cnt, $convmap) {
94 $c = isset($m[2]) ? (int) \hexdec($m[2]) : $m[1];
95 for ($i = 0; $i < $cnt; $i += 4) {
96 if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
97 return self::mb_chr($c - $convmap[$i + 2]);
98 }
99 }
100 return $m[0];
101 }, $s);
102 if (null === $encoding) {
103 return $s;
104 }
105 return \iconv('UTF-8', $encoding . '//IGNORE', $s);
106 }
107 public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = \false)
108 {
109 if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
110 \trigger_error('mb_encode_numericentity() expects parameter 1 to be string, ' . \gettype($s) . ' given', \E_USER_WARNING);
111 return null;
112 }
113 if (!\is_array($convmap) || 80000 > \PHP_VERSION_ID && !$convmap) {
114 return \false;
115 }
116 if (null !== $encoding && !\is_scalar($encoding)) {
117 \trigger_error('mb_encode_numericentity() expects parameter 3 to be string, ' . \gettype($s) . ' given', \E_USER_WARNING);
118 return null;
119 // Instead of '' (cf. mb_decode_numericentity).
120 }
121 if (null !== $is_hex && !\is_scalar($is_hex)) {
122 \trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, ' . \gettype($s) . ' given', \E_USER_WARNING);
123 return null;
124 }
125 $s = (string) $s;
126 if ('' === $s) {
127 return '';
128 }
129 $encoding = self::getEncoding($encoding);
130 if ('UTF-8' === $encoding) {
131 $encoding = null;
132 if (!\preg_match('//u', $s)) {
133 $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
134 }
135 } else {
136 $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
137 }
138 static $ulenMask = ["\xc0" => 2, "\xd0" => 2, "\xe0" => 3, "\xf0" => 4];
139 $cnt = \floor(\count($convmap) / 4) * 4;
140 $i = 0;
141 $len = \strlen($s);
142 $result = '';
143 while ($i < $len) {
144 $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xf0"];
145 $uchr = \substr($s, $i, $ulen);
146 $i += $ulen;
147 $c = self::mb_ord($uchr);
148 for ($j = 0; $j < $cnt; $j += 4) {
149 if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
150 $cOffset = $c + $convmap[$j + 2] & $convmap[$j + 3];
151 $result .= $is_hex ? \sprintf('&#x%X;', $cOffset) : '&#' . $cOffset . ';';
152 continue 2;
153 }
154 }
155 $result .= $uchr;
156 }
157 if (null === $encoding) {
158 return $result;
159 }
160 return \iconv('UTF-8', $encoding . '//IGNORE', $result);
161 }
162 public static function mb_convert_case($s, $mode, $encoding = null)
163 {
164 $s = (string) $s;
165 if ('' === $s) {
166 return '';
167 }
168 $encoding = self::getEncoding($encoding);
169 if ('UTF-8' === $encoding) {
170 $encoding = null;
171 if (!\preg_match('//u', $s)) {
172 $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
173 }
174 } else {
175 $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
176 }
177 if (\MB_CASE_TITLE == $mode) {
178 static $titleRegexp = null;
179 if (null === $titleRegexp) {
180 $titleRegexp = self::getData('titleCaseRegexp');
181 }
182 $s = \preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s);
183 } else {
184 if (\MB_CASE_UPPER == $mode) {
185 static $upper = null;
186 if (null === $upper) {
187 $upper = self::getData('upperCase');
188 }
189 $map = $upper;
190 } else {
191 if (self::MB_CASE_FOLD === $mode) {
192 static $caseFolding = null;
193 if (null === $caseFolding) {
194 $caseFolding = self::getData('caseFolding');
195 }
196 $s = \strtr($s, $caseFolding);
197 }
198 static $lower = null;
199 if (null === $lower) {
200 $lower = self::getData('lowerCase');
201 }
202 $map = $lower;
203 }
204 static $ulenMask = ["\xc0" => 2, "\xd0" => 2, "\xe0" => 3, "\xf0" => 4];
205 $i = 0;
206 $len = \strlen($s);
207 while ($i < $len) {
208 $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xf0"];
209 $uchr = \substr($s, $i, $ulen);
210 $i += $ulen;
211 if (isset($map[$uchr])) {
212 $uchr = $map[$uchr];
213 $nlen = \strlen($uchr);
214 if ($nlen == $ulen) {
215 $nlen = $i;
216 do {
217 $s[--$nlen] = $uchr[--$ulen];
218 } while ($ulen);
219 } else {
220 $s = \substr_replace($s, $uchr, $i - $ulen, $ulen);
221 $len += $nlen - $ulen;
222 $i += $nlen - $ulen;
223 }
224 }
225 }
226 }
227 if (null === $encoding) {
228 return $s;
229 }
230 return \iconv('UTF-8', $encoding . '//IGNORE', $s);
231 }
232 public static function mb_internal_encoding($encoding = null)
233 {
234 if (null === $encoding) {
235 return self::$internalEncoding;
236 }
237 $normalizedEncoding = self::getEncoding($encoding);
238 if ('UTF-8' === $normalizedEncoding || \false !== @\iconv($normalizedEncoding, $normalizedEncoding, ' ')) {
239 self::$internalEncoding = $normalizedEncoding;
240 return \true;
241 }
242 if (80000 > \PHP_VERSION_ID) {
243 return \false;
244 }
245 throw new \ValueError(\sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
246 }
247 public static function mb_language($lang = null)
248 {
249 if (null === $lang) {
250 return self::$language;
251 }
252 switch ($normalizedLang = \strtolower($lang)) {
253 case 'uni':
254 case 'neutral':
255 self::$language = $normalizedLang;
256 return \true;
257 }
258 if (80000 > \PHP_VERSION_ID) {
259 return \false;
260 }
261 throw new \ValueError(\sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
262 }
263 public static function mb_list_encodings()
264 {
265 return ['UTF-8'];
266 }
267 public static function mb_encoding_aliases($encoding)
268 {
269 switch (\strtoupper($encoding)) {
270 case 'UTF8':
271 case 'UTF-8':
272 return ['utf8'];
273 }
274 return \false;
275 }
276 public static function mb_check_encoding($var = null, $encoding = null)
277 {
278 if (\PHP_VERSION_ID < 70200 && \is_array($var)) {
279 \trigger_error('mb_check_encoding() expects parameter 1 to be string, array given', \E_USER_WARNING);
280 return null;
281 }
282 if (null === $encoding) {
283 if (null === $var) {
284 return \false;
285 }
286 $encoding = self::$internalEncoding;
287 }
288 if (!\is_array($var)) {
289 return self::mb_detect_encoding($var, [$encoding]) || \false !== @\iconv($encoding, $encoding, $var);
290 }
291 foreach ($var as $key => $value) {
292 if (!self::mb_check_encoding($key, $encoding)) {
293 return \false;
294 }
295 if (!self::mb_check_encoding($value, $encoding)) {
296 return \false;
297 }
298 }
299 return \true;
300 }
301 public static function mb_detect_encoding($str, $encodingList = null, $strict = \false)
302 {
303 if (null === $encodingList) {
304 $encodingList = self::$encodingList;
305 } else {
306 if (!\is_array($encodingList)) {
307 $encodingList = \array_map('trim', \explode(',', $encodingList));
308 }
309 $encodingList = \array_map('strtoupper', $encodingList);
310 }
311 foreach ($encodingList as $enc) {
312 switch ($enc) {
313 case 'ASCII':
314 if (!\preg_match('/[\\x80-\\xFF]/', $str)) {
315 return $enc;
316 }
317 break;
318 case 'UTF8':
319 case 'UTF-8':
320 if (\preg_match('//u', $str)) {
321 return 'UTF-8';
322 }
323 break;
324 default:
325 if (0 === \strncmp($enc, 'ISO-8859-', 9)) {
326 return $enc;
327 }
328 }
329 }
330 return \false;
331 }
332 public static function mb_detect_order($encodingList = null)
333 {
334 if (null === $encodingList) {
335 return self::$encodingList;
336 }
337 if (!\is_array($encodingList)) {
338 $encodingList = \array_map('trim', \explode(',', $encodingList));
339 }
340 $encodingList = \array_map('strtoupper', $encodingList);
341 foreach ($encodingList as $enc) {
342 switch ($enc) {
343 default:
344 if (\strncmp($enc, 'ISO-8859-', 9)) {
345 return \false;
346 }
347 // no break
348 case 'ASCII':
349 case 'UTF8':
350 case 'UTF-8':
351 }
352 }
353 self::$encodingList = $encodingList;
354 return \true;
355 }
356 public static function mb_strlen($s, $encoding = null)
357 {
358 $encoding = self::getEncoding($encoding);
359 if ('CP850' === $encoding || 'ASCII' === $encoding) {
360 return \strlen($s);
361 }
362 return @\iconv_strlen($s, $encoding);
363 }
364 public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
365 {
366 $encoding = self::getEncoding($encoding);
367 if ('CP850' === $encoding || 'ASCII' === $encoding) {
368 return \strpos($haystack, $needle, $offset);
369 }
370 $needle = (string) $needle;
371 if ('' === $needle) {
372 if (80000 > \PHP_VERSION_ID) {
373 \trigger_error(__METHOD__ . ': Empty delimiter', \E_USER_WARNING);
374 return \false;
375 }
376 return 0;
377 }
378 return \iconv_strpos($haystack, $needle, $offset, $encoding);
379 }
380 public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
381 {
382 $encoding = self::getEncoding($encoding);
383 if ('CP850' === $encoding || 'ASCII' === $encoding) {
384 return \strrpos($haystack, $needle, $offset);
385 }
386 if ($offset != (int) $offset) {
387 $offset = 0;
388 } elseif ($offset = (int) $offset) {
389 if ($offset < 0) {
390 if (0 > ($offset += self::mb_strlen($needle))) {
391 $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
392 }
393 $offset = 0;
394 } else {
395 $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
396 }
397 }
398 $pos = '' !== $needle || 80000 > \PHP_VERSION_ID ? \iconv_strrpos($haystack, $needle, $encoding) : self::mb_strlen($haystack, $encoding);
399 return \false !== $pos ? $offset + $pos : \false;
400 }
401 public static function mb_str_split($string, $split_length = 1, $encoding = null)
402 {
403 if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
404 \trigger_error('mb_str_split() expects parameter 1 to be string, ' . \gettype($string) . ' given', \E_USER_WARNING);
405 return null;
406 }
407 if (1 > ($split_length = (int) $split_length)) {
408 if (80000 > \PHP_VERSION_ID) {
409 \trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
410 return \false;
411 }
412 throw new \ValueError('Argument #2 ($length) must be greater than 0');
413 }
414 if (null === $encoding) {
415 $encoding = \mb_internal_encoding();
416 }
417 if ('UTF-8' === ($encoding = self::getEncoding($encoding))) {
418 $rx = '/(';
419 while (65535 < $split_length) {
420 $rx .= '.{65535}';
421 $split_length -= 65535;
422 }
423 $rx .= '.{' . $split_length . '})/us';
424 return \preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
425 }
426 $result = [];
427 $length = \mb_strlen($string, $encoding);
428 for ($i = 0; $i < $length; $i += $split_length) {
429 $result[] = \mb_substr($string, $i, $split_length, $encoding);
430 }
431 return $result;
432 }
433 public static function mb_strtolower($s, $encoding = null)
434 {
435 return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding);
436 }
437 public static function mb_strtoupper($s, $encoding = null)
438 {
439 return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding);
440 }
441 public static function mb_substitute_character($c = null)
442 {
443 if (null === $c) {
444 return 'none';
445 }
446 if (0 === \strcasecmp($c, 'none')) {
447 return \true;
448 }
449 if (80000 > \PHP_VERSION_ID) {
450 return \false;
451 }
452 if (\is_int($c) || 'long' === $c || 'entity' === $c) {
453 return \false;
454 }
455 throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
456 }
457 public static function mb_substr($s, $start, $length = null, $encoding = null)
458 {
459 $encoding = self::getEncoding($encoding);
460 if ('CP850' === $encoding || 'ASCII' === $encoding) {
461 return (string) \substr($s, $start, null === $length ? 2147483647 : $length);
462 }
463 if ($start < 0) {
464 $start = \iconv_strlen($s, $encoding) + $start;
465 if ($start < 0) {
466 $start = 0;
467 }
468 }
469 if (null === $length) {
470 $length = 2147483647;
471 } elseif ($length < 0) {
472 $length = \iconv_strlen($s, $encoding) + $length - $start;
473 if ($length < 0) {
474 return '';
475 }
476 }
477 return (string) \iconv_substr($s, $start, $length, $encoding);
478 }
479 public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
480 {
481 [$haystack, $needle] = \str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], [self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding), self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding)]);
482 return self::mb_strpos($haystack, $needle, $offset, $encoding);
483 }
484 public static function mb_stristr($haystack, $needle, $part = \false, $encoding = null)
485 {
486 $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
487 return self::getSubpart($pos, $part, $haystack, $encoding);
488 }
489 public static function mb_strrchr($haystack, $needle, $part = \false, $encoding = null)
490 {
491 $encoding = self::getEncoding($encoding);
492 if ('CP850' === $encoding || 'ASCII' === $encoding) {
493 $pos = \strrpos($haystack, $needle);
494 } else {
495 $needle = self::mb_substr($needle, 0, 1, $encoding);
496 $pos = \iconv_strrpos($haystack, $needle, $encoding);
497 }
498 return self::getSubpart($pos, $part, $haystack, $encoding);
499 }
500 public static function mb_strrichr($haystack, $needle, $part = \false, $encoding = null)
501 {
502 $needle = self::mb_substr($needle, 0, 1, $encoding);
503 $pos = self::mb_strripos($haystack, $needle, $encoding);
504 return self::getSubpart($pos, $part, $haystack, $encoding);
505 }
506 public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
507 {
508 $haystack = self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding);
509 $needle = self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding);
510 $haystack = \str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $haystack);
511 $needle = \str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $needle);
512 return self::mb_strrpos($haystack, $needle, $offset, $encoding);
513 }
514 public static function mb_strstr($haystack, $needle, $part = \false, $encoding = null)
515 {
516 $pos = \strpos($haystack, $needle);
517 if (\false === $pos) {
518 return \false;
519 }
520 if ($part) {
521 return \substr($haystack, 0, $pos);
522 }
523 return \substr($haystack, $pos);
524 }
525 public static function mb_get_info($type = 'all')
526 {
527 $info = ['internal_encoding' => self::$internalEncoding, 'http_output' => 'pass', 'http_output_conv_mimetypes' => '^(text/|application/xhtml\\+xml)', 'func_overload' => 0, 'func_overload_list' => 'no overload', 'mail_charset' => 'UTF-8', 'mail_header_encoding' => 'BASE64', 'mail_body_encoding' => 'BASE64', 'illegal_chars' => 0, 'encoding_translation' => 'Off', 'language' => self::$language, 'detect_order' => self::$encodingList, 'substitute_character' => 'none', 'strict_detection' => 'Off'];
528 if ('all' === $type) {
529 return $info;
530 }
531 if (isset($info[$type])) {
532 return $info[$type];
533 }
534 return \false;
535 }
536 public static function mb_http_input($type = '')
537 {
538 return \false;
539 }
540 public static function mb_http_output($encoding = null)
541 {
542 return null !== $encoding ? 'pass' === $encoding : 'pass';
543 }
544 public static function mb_strwidth($s, $encoding = null)
545 {
546 $encoding = self::getEncoding($encoding);
547 if ('UTF-8' !== $encoding) {
548 $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
549 }
550 $s = \preg_replace('/[\\x{1100}-\\x{115F}\\x{2329}\\x{232A}\\x{2E80}-\\x{303E}\\x{3040}-\\x{A4CF}\\x{AC00}-\\x{D7A3}\\x{F900}-\\x{FAFF}\\x{FE10}-\\x{FE19}\\x{FE30}-\\x{FE6F}\\x{FF00}-\\x{FF60}\\x{FFE0}-\\x{FFE6}\\x{20000}-\\x{2FFFD}\\x{30000}-\\x{3FFFD}]/u', '', $s, -1, $wide);
551 return ($wide << 1) + \iconv_strlen($s, 'UTF-8');
552 }
553 public static function mb_substr_count($haystack, $needle, $encoding = null)
554 {
555 return \substr_count($haystack, $needle);
556 }
557 public static function mb_output_handler($contents, $status)
558 {
559 return $contents;
560 }
561 public static function mb_chr($code, $encoding = null)
562 {
563 if (0x80 > ($code %= 0x200000)) {
564 $s = \chr($code);
565 } elseif (0x800 > $code) {
566 $s = \chr(0xc0 | $code >> 6) . \chr(0x80 | $code & 0x3f);
567 } elseif (0x10000 > $code) {
568 $s = \chr(0xe0 | $code >> 12) . \chr(0x80 | $code >> 6 & 0x3f) . \chr(0x80 | $code & 0x3f);
569 } else {
570 $s = \chr(0xf0 | $code >> 18) . \chr(0x80 | $code >> 12 & 0x3f) . \chr(0x80 | $code >> 6 & 0x3f) . \chr(0x80 | $code & 0x3f);
571 }
572 if ('UTF-8' !== ($encoding = self::getEncoding($encoding))) {
573 $s = \mb_convert_encoding($s, $encoding, 'UTF-8');
574 }
575 return $s;
576 }
577 public static function mb_ord($s, $encoding = null)
578 {
579 if ('UTF-8' !== ($encoding = self::getEncoding($encoding))) {
580 $s = \mb_convert_encoding($s, 'UTF-8', $encoding);
581 }
582 if (1 === \strlen($s)) {
583 return \ord($s);
584 }
585 $code = ($s = \unpack('C*', \substr($s, 0, 4))) ? $s[1] : 0;
586 if (0xf0 <= $code) {
587 return ($code - 0xf0 << 18) + ($s[2] - 0x80 << 12) + ($s[3] - 0x80 << 6) + $s[4] - 0x80;
588 }
589 if (0xe0 <= $code) {
590 return ($code - 0xe0 << 12) + ($s[2] - 0x80 << 6) + $s[3] - 0x80;
591 }
592 if (0xc0 <= $code) {
593 return ($code - 0xc0 << 6) + $s[2] - 0x80;
594 }
595 return $code;
596 }
597 public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT,?string $encoding = null) : string
598 {
599 if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], \true)) {
600 throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
601 }
602 if (null === $encoding) {
603 $encoding = self::mb_internal_encoding();
604 }
605 try {
606 $validEncoding = @self::mb_check_encoding('', $encoding);
607 } catch (\ValueError $e) {
608 throw new \ValueError(\sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
609 }
610 // BC for PHP 7.3 and lower
611 if (!$validEncoding) {
612 throw new \ValueError(\sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
613 }
614 if (self::mb_strlen($pad_string, $encoding) <= 0) {
615 throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
616 }
617 $paddingRequired = $length - self::mb_strlen($string, $encoding);
618 if ($paddingRequired < 1) {
619 return $string;
620 }
621 switch ($pad_type) {
622 case \STR_PAD_LEFT:
623 return self::mb_substr(\str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding) . $string;
624 case \STR_PAD_RIGHT:
625 return $string . self::mb_substr(\str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding);
626 default:
627 $leftPaddingLength = \floor($paddingRequired / 2);
628 $rightPaddingLength = $paddingRequired - $leftPaddingLength;
629 return self::mb_substr(\str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding) . $string . self::mb_substr(\str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
630 }
631 }
632 private static function getSubpart($pos, $part, $haystack, $encoding)
633 {
634 if (\false === $pos) {
635 return \false;
636 }
637 if ($part) {
638 return self::mb_substr($haystack, 0, $pos, $encoding);
639 }
640 return self::mb_substr($haystack, $pos, null, $encoding);
641 }
642 private static function html_encoding_callback(array $m)
643 {
644 $i = 1;
645 $entities = '';
646 $m = \unpack('C*', \htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
647 while (isset($m[$i])) {
648 if (0x80 > $m[$i]) {
649 $entities .= \chr($m[$i++]);
650 continue;
651 }
652 if (0xf0 <= $m[$i]) {
653 $c = ($m[$i++] - 0xf0 << 18) + ($m[$i++] - 0x80 << 12) + ($m[$i++] - 0x80 << 6) + $m[$i++] - 0x80;
654 } elseif (0xe0 <= $m[$i]) {
655 $c = ($m[$i++] - 0xe0 << 12) + ($m[$i++] - 0x80 << 6) + $m[$i++] - 0x80;
656 } else {
657 $c = ($m[$i++] - 0xc0 << 6) + $m[$i++] - 0x80;
658 }
659 $entities .= '&#' . $c . ';';
660 }
661 return $entities;
662 }
663 private static function title_case(array $s)
664 {
665 return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8') . self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8');
666 }
667 private static function getData($file)
668 {
669 if (\file_exists($file = __DIR__ . '/Resources/unidata/' . $file . '.php')) {
670 return require $file;
671 }
672 return \false;
673 }
674 private static function getEncoding($encoding)
675 {
676 if (null === $encoding) {
677 return self::$internalEncoding;
678 }
679 if ('UTF-8' === $encoding) {
680 return 'UTF-8';
681 }
682 $encoding = \strtoupper($encoding);
683 if ('8BIT' === $encoding || 'BINARY' === $encoding) {
684 return 'CP850';
685 }
686 if ('UTF8' === $encoding) {
687 return 'UTF-8';
688 }
689 return $encoding;
690 }
691 }
692