Version Description
(2020-11-30) =
- Fixed PHP multibyte fallback support when the iconv extension is missing
Download this release
Release Info
Developer | geminilabs |
Plugin | Site Reviews |
Version | 5.2.3 |
Comparing to | |
See all releases |
Code changes from version 5.2.2 to 5.2.3
- plugin/Modules/Validator.php +1 -3
- readme.txt +6 -2
- site-reviews.php +1 -1
- vendors/symfony/polyfill-mbstring/Mbstring.php +53 -658
- vendors/symfony/polyfill-mbstring/bootstrap.php +7 -103
plugin/Modules/Validator.php
CHANGED
@@ -190,9 +190,7 @@ class Validator
|
|
190 |
} elseif (is_array($value)) {
|
191 |
return count($value);
|
192 |
}
|
193 |
-
return
|
194 |
-
? mb_strlen($value)
|
195 |
-
: strlen($value);
|
196 |
}
|
197 |
|
198 |
/**
|
190 |
} elseif (is_array($value)) {
|
191 |
return count($value);
|
192 |
}
|
193 |
+
return mb_strlen($value);
|
|
|
|
|
194 |
}
|
195 |
|
196 |
/**
|
readme.txt
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
Contributors: geminilabs, pryley
|
3 |
Donate link: https://www.paypal.me/pryley
|
4 |
Tags: reviews, ratings, testimonials, business reviews, product reviews, stars, star ratings
|
5 |
-
Tested up to: 5.
|
6 |
Requires at least: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 5.2.
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -113,6 +113,10 @@ All documentation can be found in the "Help" page of the plugin. If your questio
|
|
113 |
|
114 |
== Changelog ==
|
115 |
|
|
|
|
|
|
|
|
|
116 |
= 5.2.2 (2020-11-17) =
|
117 |
|
118 |
- Fixed shortcode examples in documentation; Copy/pasting a shortcode example into the classic editor will now paste as plain text instead of as HTML code.
|
2 |
Contributors: geminilabs, pryley
|
3 |
Donate link: https://www.paypal.me/pryley
|
4 |
Tags: reviews, ratings, testimonials, business reviews, product reviews, stars, star ratings
|
5 |
+
Tested up to: 5.6
|
6 |
Requires at least: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 5.2.3
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
113 |
|
114 |
== Changelog ==
|
115 |
|
116 |
+
= 5.2.3 (2020-11-30) =
|
117 |
+
|
118 |
+
- Fixed PHP multibyte fallback support when the iconv extension is missing
|
119 |
+
|
120 |
= 5.2.2 (2020-11-17) =
|
121 |
|
122 |
- Fixed shortcode examples in documentation; Copy/pasting a shortcode example into the classic editor will now paste as plain text instead of as HTML code.
|
site-reviews.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Plugin Name: Site Reviews
|
8 |
* Plugin URI: https://wordpress.org/plugins/site-reviews
|
9 |
* Description: Receive and display reviews on your website
|
10 |
-
* Version: 5.2.
|
11 |
* Author: Paul Ryley
|
12 |
* Author URI: https://geminilabs.io
|
13 |
* License: GPL2
|
7 |
* Plugin Name: Site Reviews
|
8 |
* Plugin URI: https://wordpress.org/plugins/site-reviews
|
9 |
* Description: Receive and display reviews on your website
|
10 |
+
* Version: 5.2.3
|
11 |
* Author: Paul Ryley
|
12 |
* Author URI: https://geminilabs.io
|
13 |
* License: GPL2
|
vendors/symfony/polyfill-mbstring/Mbstring.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This
|
4 |
-
*
|
5 |
* (c) Fabien Potencier <fabien@symfony.com>
|
6 |
*
|
7 |
* For the full copyright and license information, please view the LICENSE
|
@@ -16,15 +16,24 @@ namespace GeminiLabs\Symfony\Polyfill\Mbstring;
|
|
16 |
* Partial mbstring implementation in PHP, iconv based, UTF-8 centric.
|
17 |
*
|
18 |
* Implemented:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
* - mb_chr - Returns a specific character from its Unicode code point
|
20 |
* - mb_convert_encoding - Convert character encoding
|
|
|
21 |
* - mb_convert_variables - Convert character code in variable(s)
|
22 |
* - mb_decode_mimeheader - Decode string in MIME header field
|
23 |
-
* - mb_encode_mimeheader - Encode string for MIME header XXX NATIVE IMPLEMENTATION IS REALLY BUGGED
|
24 |
* - mb_decode_numericentity - Decode HTML numeric string reference to character
|
25 |
-
* - mb_encode_numericentity - Encode character to HTML numeric string reference
|
26 |
-
* - mb_convert_case - Perform case folding on a string
|
27 |
* - mb_detect_encoding - Detect character encoding
|
|
|
|
|
|
|
28 |
* - mb_get_info - Get internal settings of mbstring
|
29 |
* - mb_http_input - Detect HTTP input character encoding
|
30 |
* - mb_http_output - Set/Get HTTP output character encoding
|
@@ -32,39 +41,26 @@ namespace GeminiLabs\Symfony\Polyfill\Mbstring;
|
|
32 |
* - mb_list_encodings - Returns an array of all supported encodings
|
33 |
* - mb_ord - Returns the Unicode code point of a character
|
34 |
* - mb_output_handler - Callback function converts character encoding in output buffer
|
|
|
|
|
|
|
|
|
35 |
* - mb_scrub - Replaces ill-formed byte sequences with substitute characters
|
36 |
-
* -
|
37 |
-
* -
|
38 |
-
* - mb_strrpos - Find position of last occurrence of a string in a string
|
39 |
* - mb_str_split - Convert a string to an array
|
40 |
-
* -
|
41 |
-
* -
|
42 |
-
* - mb_substitute_character - Set/Get substitution character
|
43 |
-
* - mb_substr - Get part of string
|
44 |
* - mb_stripos - Finds position of first occurrence of a string within another, case insensitive
|
45 |
* - mb_stristr - Finds first occurrence of a string within another, case insensitive
|
|
|
46 |
* - mb_strrchr - Finds the last occurrence of a character in a string within another
|
47 |
* - mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive
|
48 |
* - mb_strripos - Finds position of last occurrence of a string within another, case insensitive
|
|
|
49 |
* - mb_strstr - Finds first occurrence of a string within another
|
50 |
-
* -
|
51 |
* - mb_substr_count - Count the number of substring occurrences
|
52 |
-
*
|
53 |
-
* Not implemented:
|
54 |
-
* - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more)
|
55 |
-
* - mb_ereg_* - Regular expression with multibyte support
|
56 |
-
* - mb_parse_str - Parse GET/POST/COOKIE data and set global variable
|
57 |
-
* - mb_preferred_mime_name - Get MIME charset string
|
58 |
-
* - mb_regex_encoding - Returns current encoding for multibyte regex as string
|
59 |
-
* - mb_regex_set_options - Set/Get the default options for mbregex functions
|
60 |
-
* - mb_send_mail - Send encoded mail
|
61 |
-
* - mb_split - Split multibyte string using regular expression
|
62 |
-
* - mb_strcut - Get part of string
|
63 |
-
* - mb_strimwidth - Get truncated string with specified width
|
64 |
-
*
|
65 |
-
* @author Nicolas Grekas <p@tchwork.com>
|
66 |
-
*
|
67 |
-
* @internal
|
68 |
*/
|
69 |
final class Mbstring
|
70 |
{
|
@@ -78,207 +74,22 @@ final class Mbstring
|
|
78 |
array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'),
|
79 |
);
|
80 |
|
81 |
-
public static function
|
82 |
-
{
|
83 |
-
if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
|
84 |
-
$fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
|
85 |
-
} else {
|
86 |
-
$fromEncoding = self::getEncoding($fromEncoding);
|
87 |
-
}
|
88 |
-
|
89 |
-
$toEncoding = self::getEncoding($toEncoding);
|
90 |
-
|
91 |
-
if ('BASE64' === $fromEncoding) {
|
92 |
-
$s = base64_decode($s);
|
93 |
-
$fromEncoding = $toEncoding;
|
94 |
-
}
|
95 |
-
|
96 |
-
if ('BASE64' === $toEncoding) {
|
97 |
-
return base64_encode($s);
|
98 |
-
}
|
99 |
-
|
100 |
-
if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
|
101 |
-
if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
|
102 |
-
$fromEncoding = 'Windows-1252';
|
103 |
-
}
|
104 |
-
if ('UTF-8' !== $fromEncoding) {
|
105 |
-
$s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
|
106 |
-
}
|
107 |
-
|
108 |
-
return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
|
109 |
-
}
|
110 |
-
|
111 |
-
if ('HTML-ENTITIES' === $fromEncoding) {
|
112 |
-
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
|
113 |
-
$fromEncoding = 'UTF-8';
|
114 |
-
}
|
115 |
-
|
116 |
-
return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
|
117 |
-
}
|
118 |
-
|
119 |
-
public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
|
120 |
-
{
|
121 |
-
$vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
|
122 |
-
|
123 |
-
$ok = true;
|
124 |
-
array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
|
125 |
-
if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
|
126 |
-
$ok = false;
|
127 |
-
}
|
128 |
-
});
|
129 |
-
|
130 |
-
return $ok ? $fromEncoding : false;
|
131 |
-
}
|
132 |
-
|
133 |
-
public static function mb_decode_mimeheader($s)
|
134 |
-
{
|
135 |
-
return iconv_mime_decode($s, 2, self::$internalEncoding);
|
136 |
-
}
|
137 |
-
|
138 |
-
public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
|
139 |
-
{
|
140 |
-
trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
|
141 |
-
}
|
142 |
-
|
143 |
-
public static function mb_decode_numericentity($s, $convmap, $encoding = null)
|
144 |
{
|
145 |
-
if (
|
146 |
-
|
147 |
-
|
148 |
-
return null;
|
149 |
-
}
|
150 |
-
|
151 |
-
if (!\is_array($convmap) || !$convmap) {
|
152 |
-
return false;
|
153 |
-
}
|
154 |
-
|
155 |
-
if (null !== $encoding && !\is_scalar($encoding)) {
|
156 |
-
trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
|
157 |
-
|
158 |
-
return ''; // Instead of null (cf. mb_encode_numericentity).
|
159 |
-
}
|
160 |
-
|
161 |
-
$s = (string) $s;
|
162 |
-
if ('' === $s) {
|
163 |
-
return '';
|
164 |
-
}
|
165 |
-
|
166 |
-
$encoding = self::getEncoding($encoding);
|
167 |
-
|
168 |
-
if ('UTF-8' === $encoding) {
|
169 |
-
$encoding = null;
|
170 |
-
if (!preg_match('//u', $s)) {
|
171 |
-
$s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
|
172 |
}
|
173 |
-
|
174 |
-
|
175 |
-
}
|
176 |
-
|
177 |
-
$cnt = floor(\count($convmap) / 4) * 4;
|
178 |
-
|
179 |
-
for ($i = 0; $i < $cnt; $i += 4) {
|
180 |
-
// collector_decode_htmlnumericentity ignores $convmap[$i + 3]
|
181 |
-
$convmap[$i] += $convmap[$i + 2];
|
182 |
-
$convmap[$i + 1] += $convmap[$i + 2];
|
183 |
-
}
|
184 |
-
|
185 |
-
$s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
|
186 |
-
$c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
|
187 |
-
for ($i = 0; $i < $cnt; $i += 4) {
|
188 |
-
if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
|
189 |
-
return Mbstring::mb_chr($c - $convmap[$i + 2]);
|
190 |
-
}
|
191 |
}
|
192 |
-
|
193 |
-
return $m[0];
|
194 |
-
}, $s);
|
195 |
-
|
196 |
-
if (null === $encoding) {
|
197 |
return $s;
|
198 |
}
|
199 |
-
|
200 |
-
return iconv('UTF-8', $encoding.'//IGNORE', $s);
|
201 |
-
}
|
202 |
-
|
203 |
-
public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
|
204 |
-
{
|
205 |
-
if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
|
206 |
-
trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
|
207 |
-
|
208 |
-
return null;
|
209 |
-
}
|
210 |
-
|
211 |
-
if (!\is_array($convmap) || !$convmap) {
|
212 |
-
return false;
|
213 |
-
}
|
214 |
-
|
215 |
-
if (null !== $encoding && !\is_scalar($encoding)) {
|
216 |
-
trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
|
217 |
-
|
218 |
-
return null; // Instead of '' (cf. mb_decode_numericentity).
|
219 |
-
}
|
220 |
-
|
221 |
-
if (null !== $is_hex && !\is_scalar($is_hex)) {
|
222 |
-
trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
|
223 |
-
|
224 |
-
return null;
|
225 |
-
}
|
226 |
-
|
227 |
-
$s = (string) $s;
|
228 |
-
if ('' === $s) {
|
229 |
-
return '';
|
230 |
-
}
|
231 |
-
|
232 |
-
$encoding = self::getEncoding($encoding);
|
233 |
-
|
234 |
-
if ('UTF-8' === $encoding) {
|
235 |
-
$encoding = null;
|
236 |
-
if (!preg_match('//u', $s)) {
|
237 |
-
$s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
|
238 |
-
}
|
239 |
-
} else {
|
240 |
-
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
241 |
-
}
|
242 |
-
|
243 |
-
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
|
244 |
-
|
245 |
-
$cnt = floor(\count($convmap) / 4) * 4;
|
246 |
-
$i = 0;
|
247 |
-
$len = \strlen($s);
|
248 |
-
$result = '';
|
249 |
-
|
250 |
-
while ($i < $len) {
|
251 |
-
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
|
252 |
-
$uchr = substr($s, $i, $ulen);
|
253 |
-
$i += $ulen;
|
254 |
-
$c = self::mb_ord($uchr);
|
255 |
-
|
256 |
-
for ($j = 0; $j < $cnt; $j += 4) {
|
257 |
-
if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
|
258 |
-
$cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
|
259 |
-
$result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
|
260 |
-
continue 2;
|
261 |
-
}
|
262 |
-
}
|
263 |
-
$result .= $uchr;
|
264 |
-
}
|
265 |
-
|
266 |
-
if (null === $encoding) {
|
267 |
-
return $result;
|
268 |
-
}
|
269 |
-
|
270 |
-
return iconv('UTF-8', $encoding.'//IGNORE', $result);
|
271 |
-
}
|
272 |
-
|
273 |
-
public static function mb_convert_case($s, $mode, $encoding = null)
|
274 |
-
{
|
275 |
$s = (string) $s;
|
276 |
if ('' === $s) {
|
277 |
return '';
|
278 |
}
|
279 |
-
|
280 |
$encoding = self::getEncoding($encoding);
|
281 |
-
|
282 |
if ('UTF-8' === $encoding) {
|
283 |
$encoding = null;
|
284 |
if (!preg_match('//u', $s)) {
|
@@ -287,7 +98,6 @@ final class Mbstring
|
|
287 |
} else {
|
288 |
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
289 |
}
|
290 |
-
|
291 |
if (MB_CASE_TITLE == $mode) {
|
292 |
static $titleRegexp = null;
|
293 |
if (null === $titleRegexp) {
|
@@ -305,28 +115,22 @@ final class Mbstring
|
|
305 |
if (self::MB_CASE_FOLD === $mode) {
|
306 |
$s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
|
307 |
}
|
308 |
-
|
309 |
static $lower = null;
|
310 |
if (null === $lower) {
|
311 |
$lower = self::getData('lowerCase');
|
312 |
}
|
313 |
$map = $lower;
|
314 |
}
|
315 |
-
|
316 |
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
|
317 |
-
|
318 |
$i = 0;
|
319 |
$len = \strlen($s);
|
320 |
-
|
321 |
while ($i < $len) {
|
322 |
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
|
323 |
$uchr = substr($s, $i, $ulen);
|
324 |
$i += $ulen;
|
325 |
-
|
326 |
if (isset($map[$uchr])) {
|
327 |
$uchr = $map[$uchr];
|
328 |
$nlen = \strlen($uchr);
|
329 |
-
|
330 |
if ($nlen == $ulen) {
|
331 |
$nlen = $i;
|
332 |
do {
|
@@ -340,232 +144,21 @@ final class Mbstring
|
|
340 |
}
|
341 |
}
|
342 |
}
|
343 |
-
|
344 |
if (null === $encoding) {
|
345 |
return $s;
|
346 |
}
|
347 |
-
|
348 |
return iconv('UTF-8', $encoding.'//IGNORE', $s);
|
349 |
}
|
350 |
|
351 |
-
public static function mb_internal_encoding($encoding = null)
|
352 |
-
{
|
353 |
-
if (null === $encoding) {
|
354 |
-
return self::$internalEncoding;
|
355 |
-
}
|
356 |
-
|
357 |
-
$encoding = self::getEncoding($encoding);
|
358 |
-
|
359 |
-
if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
|
360 |
-
self::$internalEncoding = $encoding;
|
361 |
-
|
362 |
-
return true;
|
363 |
-
}
|
364 |
-
|
365 |
-
return false;
|
366 |
-
}
|
367 |
-
|
368 |
-
public static function mb_language($lang = null)
|
369 |
-
{
|
370 |
-
if (null === $lang) {
|
371 |
-
return self::$language;
|
372 |
-
}
|
373 |
-
|
374 |
-
switch ($lang = strtolower($lang)) {
|
375 |
-
case 'uni':
|
376 |
-
case 'neutral':
|
377 |
-
self::$language = $lang;
|
378 |
-
|
379 |
-
return true;
|
380 |
-
}
|
381 |
-
|
382 |
-
return false;
|
383 |
-
}
|
384 |
-
|
385 |
-
public static function mb_list_encodings()
|
386 |
-
{
|
387 |
-
return array('UTF-8');
|
388 |
-
}
|
389 |
-
|
390 |
-
public static function mb_encoding_aliases($encoding)
|
391 |
-
{
|
392 |
-
switch (strtoupper($encoding)) {
|
393 |
-
case 'UTF8':
|
394 |
-
case 'UTF-8':
|
395 |
-
return array('utf8');
|
396 |
-
}
|
397 |
-
|
398 |
-
return false;
|
399 |
-
}
|
400 |
-
|
401 |
-
public static function mb_check_encoding($var = null, $encoding = null)
|
402 |
-
{
|
403 |
-
if (null === $encoding) {
|
404 |
-
if (null === $var) {
|
405 |
-
return false;
|
406 |
-
}
|
407 |
-
$encoding = self::$internalEncoding;
|
408 |
-
}
|
409 |
-
|
410 |
-
return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
|
411 |
-
}
|
412 |
-
|
413 |
-
public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
|
414 |
-
{
|
415 |
-
if (null === $encodingList) {
|
416 |
-
$encodingList = self::$encodingList;
|
417 |
-
} else {
|
418 |
-
if (!\is_array($encodingList)) {
|
419 |
-
$encodingList = array_map('trim', explode(',', $encodingList));
|
420 |
-
}
|
421 |
-
$encodingList = array_map('strtoupper', $encodingList);
|
422 |
-
}
|
423 |
-
|
424 |
-
foreach ($encodingList as $enc) {
|
425 |
-
switch ($enc) {
|
426 |
-
case 'ASCII':
|
427 |
-
if (!preg_match('/[\x80-\xFF]/', $str)) {
|
428 |
-
return $enc;
|
429 |
-
}
|
430 |
-
break;
|
431 |
-
|
432 |
-
case 'UTF8':
|
433 |
-
case 'UTF-8':
|
434 |
-
if (preg_match('//u', $str)) {
|
435 |
-
return 'UTF-8';
|
436 |
-
}
|
437 |
-
break;
|
438 |
-
|
439 |
-
default:
|
440 |
-
if (0 === strncmp($enc, 'ISO-8859-', 9)) {
|
441 |
-
return $enc;
|
442 |
-
}
|
443 |
-
}
|
444 |
-
}
|
445 |
-
|
446 |
-
return false;
|
447 |
-
}
|
448 |
-
|
449 |
-
public static function mb_detect_order($encodingList = null)
|
450 |
-
{
|
451 |
-
if (null === $encodingList) {
|
452 |
-
return self::$encodingList;
|
453 |
-
}
|
454 |
-
|
455 |
-
if (!\is_array($encodingList)) {
|
456 |
-
$encodingList = array_map('trim', explode(',', $encodingList));
|
457 |
-
}
|
458 |
-
$encodingList = array_map('strtoupper', $encodingList);
|
459 |
-
|
460 |
-
foreach ($encodingList as $enc) {
|
461 |
-
switch ($enc) {
|
462 |
-
default:
|
463 |
-
if (strncmp($enc, 'ISO-8859-', 9)) {
|
464 |
-
return false;
|
465 |
-
}
|
466 |
-
// no break
|
467 |
-
case 'ASCII':
|
468 |
-
case 'UTF8':
|
469 |
-
case 'UTF-8':
|
470 |
-
}
|
471 |
-
}
|
472 |
-
|
473 |
-
self::$encodingList = $encodingList;
|
474 |
-
|
475 |
-
return true;
|
476 |
-
}
|
477 |
-
|
478 |
public static function mb_strlen($s, $encoding = null)
|
479 |
{
|
480 |
$encoding = self::getEncoding($encoding);
|
481 |
-
if (
|
482 |
return \strlen($s);
|
483 |
}
|
484 |
-
|
485 |
return @iconv_strlen($s, $encoding);
|
486 |
}
|
487 |
|
488 |
-
public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
|
489 |
-
{
|
490 |
-
$encoding = self::getEncoding($encoding);
|
491 |
-
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
492 |
-
return strpos($haystack, $needle, $offset);
|
493 |
-
}
|
494 |
-
|
495 |
-
$needle = (string) $needle;
|
496 |
-
if ('' === $needle) {
|
497 |
-
trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
|
498 |
-
|
499 |
-
return false;
|
500 |
-
}
|
501 |
-
|
502 |
-
return iconv_strpos($haystack, $needle, $offset, $encoding);
|
503 |
-
}
|
504 |
-
|
505 |
-
public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
|
506 |
-
{
|
507 |
-
$encoding = self::getEncoding($encoding);
|
508 |
-
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
509 |
-
return strrpos($haystack, $needle, $offset);
|
510 |
-
}
|
511 |
-
|
512 |
-
if ($offset != (int) $offset) {
|
513 |
-
$offset = 0;
|
514 |
-
} elseif ($offset = (int) $offset) {
|
515 |
-
if ($offset < 0) {
|
516 |
-
if (0 > $offset += self::mb_strlen($needle)) {
|
517 |
-
$haystack = self::mb_substr($haystack, 0, $offset, $encoding);
|
518 |
-
}
|
519 |
-
$offset = 0;
|
520 |
-
} else {
|
521 |
-
$haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
|
522 |
-
}
|
523 |
-
}
|
524 |
-
|
525 |
-
$pos = iconv_strrpos($haystack, $needle, $encoding);
|
526 |
-
|
527 |
-
return false !== $pos ? $offset + $pos : false;
|
528 |
-
}
|
529 |
-
|
530 |
-
public static function mb_str_split($string, $split_length = 1, $encoding = null)
|
531 |
-
{
|
532 |
-
if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
|
533 |
-
trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
|
534 |
-
|
535 |
-
return null;
|
536 |
-
}
|
537 |
-
|
538 |
-
if (1 > $split_length = (int) $split_length) {
|
539 |
-
trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
|
540 |
-
|
541 |
-
return false;
|
542 |
-
}
|
543 |
-
|
544 |
-
if (null === $encoding) {
|
545 |
-
$encoding = mb_internal_encoding();
|
546 |
-
}
|
547 |
-
|
548 |
-
if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
|
549 |
-
$rx = '/(';
|
550 |
-
while (65535 < $split_length) {
|
551 |
-
$rx .= '.{65535}';
|
552 |
-
$split_length -= 65535;
|
553 |
-
}
|
554 |
-
$rx .= '.{'.$split_length.'})/us';
|
555 |
-
|
556 |
-
return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
557 |
-
}
|
558 |
-
|
559 |
-
$result = array();
|
560 |
-
$length = mb_strlen($string, $encoding);
|
561 |
-
|
562 |
-
for ($i = 0; $i < $length; $i += $split_length) {
|
563 |
-
$result[] = mb_substr($string, $i, $split_length, $encoding);
|
564 |
-
}
|
565 |
-
|
566 |
-
return $result;
|
567 |
-
}
|
568 |
-
|
569 |
public static function mb_strtolower($s, $encoding = null)
|
570 |
{
|
571 |
return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
|
@@ -576,29 +169,31 @@ final class Mbstring
|
|
576 |
return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
|
577 |
}
|
578 |
|
579 |
-
public static function
|
580 |
{
|
581 |
-
|
582 |
-
|
|
|
583 |
}
|
584 |
-
|
585 |
-
|
|
|
|
|
|
|
586 |
}
|
587 |
|
588 |
public static function mb_substr($s, $start, $length = null, $encoding = null)
|
589 |
{
|
590 |
$encoding = self::getEncoding($encoding);
|
591 |
-
if (
|
592 |
-
return (string) substr($s, $start, null === $length ? 2147483647 : $length);
|
593 |
}
|
594 |
-
|
595 |
if ($start < 0) {
|
596 |
$start = iconv_strlen($s, $encoding) + $start;
|
597 |
if ($start < 0) {
|
598 |
$start = 0;
|
599 |
}
|
600 |
}
|
601 |
-
|
602 |
if (null === $length) {
|
603 |
$length = 2147483647;
|
604 |
} elseif ($length < 0) {
|
@@ -607,219 +202,14 @@ final class Mbstring
|
|
607 |
return '';
|
608 |
}
|
609 |
}
|
610 |
-
|
611 |
return (string) iconv_substr($s, $start, $length, $encoding);
|
612 |
}
|
613 |
|
614 |
-
public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
|
615 |
-
{
|
616 |
-
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
|
617 |
-
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
|
618 |
-
|
619 |
-
return self::mb_strpos($haystack, $needle, $offset, $encoding);
|
620 |
-
}
|
621 |
-
|
622 |
-
public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
|
623 |
-
{
|
624 |
-
$pos = self::mb_stripos($haystack, $needle, 0, $encoding);
|
625 |
-
|
626 |
-
return self::getSubpart($pos, $part, $haystack, $encoding);
|
627 |
-
}
|
628 |
-
|
629 |
-
public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
|
630 |
-
{
|
631 |
-
$encoding = self::getEncoding($encoding);
|
632 |
-
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
633 |
-
return strrchr($haystack, $needle, $part);
|
634 |
-
}
|
635 |
-
$needle = self::mb_substr($needle, 0, 1, $encoding);
|
636 |
-
$pos = iconv_strrpos($haystack, $needle, $encoding);
|
637 |
-
|
638 |
-
return self::getSubpart($pos, $part, $haystack, $encoding);
|
639 |
-
}
|
640 |
-
|
641 |
-
public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
|
642 |
-
{
|
643 |
-
$needle = self::mb_substr($needle, 0, 1, $encoding);
|
644 |
-
$pos = self::mb_strripos($haystack, $needle, $encoding);
|
645 |
-
|
646 |
-
return self::getSubpart($pos, $part, $haystack, $encoding);
|
647 |
-
}
|
648 |
-
|
649 |
-
public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
|
650 |
-
{
|
651 |
-
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
|
652 |
-
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
|
653 |
-
|
654 |
-
return self::mb_strrpos($haystack, $needle, $offset, $encoding);
|
655 |
-
}
|
656 |
-
|
657 |
-
public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
|
658 |
-
{
|
659 |
-
$pos = strpos($haystack, $needle);
|
660 |
-
if (false === $pos) {
|
661 |
-
return false;
|
662 |
-
}
|
663 |
-
if ($part) {
|
664 |
-
return substr($haystack, 0, $pos);
|
665 |
-
}
|
666 |
-
|
667 |
-
return substr($haystack, $pos);
|
668 |
-
}
|
669 |
-
|
670 |
-
public static function mb_get_info($type = 'all')
|
671 |
-
{
|
672 |
-
$info = array(
|
673 |
-
'internal_encoding' => self::$internalEncoding,
|
674 |
-
'http_output' => 'pass',
|
675 |
-
'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
|
676 |
-
'func_overload' => 0,
|
677 |
-
'func_overload_list' => 'no overload',
|
678 |
-
'mail_charset' => 'UTF-8',
|
679 |
-
'mail_header_encoding' => 'BASE64',
|
680 |
-
'mail_body_encoding' => 'BASE64',
|
681 |
-
'illegal_chars' => 0,
|
682 |
-
'encoding_translation' => 'Off',
|
683 |
-
'language' => self::$language,
|
684 |
-
'detect_order' => self::$encodingList,
|
685 |
-
'substitute_character' => 'none',
|
686 |
-
'strict_detection' => 'Off',
|
687 |
-
);
|
688 |
-
|
689 |
-
if ('all' === $type) {
|
690 |
-
return $info;
|
691 |
-
}
|
692 |
-
if (isset($info[$type])) {
|
693 |
-
return $info[$type];
|
694 |
-
}
|
695 |
-
|
696 |
-
return false;
|
697 |
-
}
|
698 |
-
|
699 |
-
public static function mb_http_input($type = '')
|
700 |
-
{
|
701 |
-
return false;
|
702 |
-
}
|
703 |
-
|
704 |
-
public static function mb_http_output($encoding = null)
|
705 |
-
{
|
706 |
-
return null !== $encoding ? 'pass' === $encoding : 'pass';
|
707 |
-
}
|
708 |
-
|
709 |
-
public static function mb_strwidth($s, $encoding = null)
|
710 |
-
{
|
711 |
-
$encoding = self::getEncoding($encoding);
|
712 |
-
|
713 |
-
if ('UTF-8' !== $encoding) {
|
714 |
-
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
715 |
-
}
|
716 |
-
|
717 |
-
$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);
|
718 |
-
|
719 |
-
return ($wide << 1) + iconv_strlen($s, 'UTF-8');
|
720 |
-
}
|
721 |
-
|
722 |
-
public static function mb_substr_count($haystack, $needle, $encoding = null)
|
723 |
-
{
|
724 |
-
return substr_count($haystack, $needle);
|
725 |
-
}
|
726 |
-
|
727 |
-
public static function mb_output_handler($contents, $status)
|
728 |
-
{
|
729 |
-
return $contents;
|
730 |
-
}
|
731 |
-
|
732 |
-
public static function mb_chr($code, $encoding = null)
|
733 |
-
{
|
734 |
-
if (0x80 > $code %= 0x200000) {
|
735 |
-
$s = \chr($code);
|
736 |
-
} elseif (0x800 > $code) {
|
737 |
-
$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
|
738 |
-
} elseif (0x10000 > $code) {
|
739 |
-
$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
|
740 |
-
} else {
|
741 |
-
$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
|
742 |
-
}
|
743 |
-
|
744 |
-
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
|
745 |
-
$s = mb_convert_encoding($s, $encoding, 'UTF-8');
|
746 |
-
}
|
747 |
-
|
748 |
-
return $s;
|
749 |
-
}
|
750 |
-
|
751 |
-
public static function mb_ord($s, $encoding = null)
|
752 |
-
{
|
753 |
-
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
|
754 |
-
$s = mb_convert_encoding($s, 'UTF-8', $encoding);
|
755 |
-
}
|
756 |
-
|
757 |
-
if (1 === \strlen($s)) {
|
758 |
-
return \ord($s);
|
759 |
-
}
|
760 |
-
|
761 |
-
$code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
|
762 |
-
if (0xF0 <= $code) {
|
763 |
-
return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
|
764 |
-
}
|
765 |
-
if (0xE0 <= $code) {
|
766 |
-
return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
|
767 |
-
}
|
768 |
-
if (0xC0 <= $code) {
|
769 |
-
return (($code - 0xC0) << 6) + $s[2] - 0x80;
|
770 |
-
}
|
771 |
-
|
772 |
-
return $code;
|
773 |
-
}
|
774 |
-
|
775 |
-
private static function getSubpart($pos, $part, $haystack, $encoding)
|
776 |
-
{
|
777 |
-
if (false === $pos) {
|
778 |
-
return false;
|
779 |
-
}
|
780 |
-
if ($part) {
|
781 |
-
return self::mb_substr($haystack, 0, $pos, $encoding);
|
782 |
-
}
|
783 |
-
|
784 |
-
return self::mb_substr($haystack, $pos, null, $encoding);
|
785 |
-
}
|
786 |
-
|
787 |
-
private static function html_encoding_callback(array $m)
|
788 |
-
{
|
789 |
-
$i = 1;
|
790 |
-
$entities = '';
|
791 |
-
$m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
|
792 |
-
|
793 |
-
while (isset($m[$i])) {
|
794 |
-
if (0x80 > $m[$i]) {
|
795 |
-
$entities .= \chr($m[$i++]);
|
796 |
-
continue;
|
797 |
-
}
|
798 |
-
if (0xF0 <= $m[$i]) {
|
799 |
-
$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
800 |
-
} elseif (0xE0 <= $m[$i]) {
|
801 |
-
$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
802 |
-
} else {
|
803 |
-
$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
|
804 |
-
}
|
805 |
-
|
806 |
-
$entities .= '&#'.$c.';';
|
807 |
-
}
|
808 |
-
|
809 |
-
return $entities;
|
810 |
-
}
|
811 |
-
|
812 |
-
private static function title_case(array $s)
|
813 |
-
{
|
814 |
-
return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
|
815 |
-
}
|
816 |
-
|
817 |
private static function getData($file)
|
818 |
{
|
819 |
if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
|
820 |
return require $file;
|
821 |
}
|
822 |
-
|
823 |
return false;
|
824 |
}
|
825 |
|
@@ -828,21 +218,26 @@ final class Mbstring
|
|
828 |
if (null === $encoding) {
|
829 |
return self::$internalEncoding;
|
830 |
}
|
831 |
-
|
832 |
if ('UTF-8' === $encoding) {
|
833 |
return 'UTF-8';
|
834 |
}
|
835 |
-
|
836 |
$encoding = strtoupper($encoding);
|
837 |
-
|
838 |
if ('8BIT' === $encoding || 'BINARY' === $encoding) {
|
839 |
return 'CP850';
|
840 |
}
|
841 |
-
|
842 |
if ('UTF8' === $encoding) {
|
843 |
return 'UTF-8';
|
844 |
}
|
845 |
-
|
846 |
return $encoding;
|
847 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
848 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This is an extract of the symfony/polyfill-mbstring package.
|
4 |
+
*
|
5 |
* (c) Fabien Potencier <fabien@symfony.com>
|
6 |
*
|
7 |
* For the full copyright and license information, please view the LICENSE
|
16 |
* Partial mbstring implementation in PHP, iconv based, UTF-8 centric.
|
17 |
*
|
18 |
* Implemented:
|
19 |
+
* - mb_convert_case - Perform case folding on a string
|
20 |
+
* - mb_strlen - Get string length
|
21 |
+
* - mb_strtolower - Make a string lowercase
|
22 |
+
* - mb_strtoupper - Make a string uppercase
|
23 |
+
* - mb_strwidth - Return width of string
|
24 |
+
* - mb_substr - Get part of string
|
25 |
+
*
|
26 |
+
* Not implemented:
|
27 |
* - mb_chr - Returns a specific character from its Unicode code point
|
28 |
* - mb_convert_encoding - Convert character encoding
|
29 |
+
* - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more)
|
30 |
* - mb_convert_variables - Convert character code in variable(s)
|
31 |
* - mb_decode_mimeheader - Decode string in MIME header field
|
|
|
32 |
* - mb_decode_numericentity - Decode HTML numeric string reference to character
|
|
|
|
|
33 |
* - mb_detect_encoding - Detect character encoding
|
34 |
+
* - mb_encode_mimeheader - Encode string for MIME header XXX NATIVE IMPLEMENTATION IS REALLY BUGGED
|
35 |
+
* - mb_encode_numericentity - Encode character to HTML numeric string reference
|
36 |
+
* - mb_ereg_* - Regular expression with multibyte support
|
37 |
* - mb_get_info - Get internal settings of mbstring
|
38 |
* - mb_http_input - Detect HTTP input character encoding
|
39 |
* - mb_http_output - Set/Get HTTP output character encoding
|
41 |
* - mb_list_encodings - Returns an array of all supported encodings
|
42 |
* - mb_ord - Returns the Unicode code point of a character
|
43 |
* - mb_output_handler - Callback function converts character encoding in output buffer
|
44 |
+
* - mb_parse_str - Parse GET/POST/COOKIE data and set global variable
|
45 |
+
* - mb_preferred_mime_name - Get MIME charset string
|
46 |
+
* - mb_regex_encoding - Returns current encoding for multibyte regex as string
|
47 |
+
* - mb_regex_set_options - Set/Get the default options for mbregex functions
|
48 |
* - mb_scrub - Replaces ill-formed byte sequences with substitute characters
|
49 |
+
* - mb_send_mail - Send encoded mail
|
50 |
+
* - mb_split - Split multibyte string using regular expression
|
|
|
51 |
* - mb_str_split - Convert a string to an array
|
52 |
+
* - mb_strcut - Get part of string
|
53 |
+
* - mb_strimwidth - Get truncated string with specified width
|
|
|
|
|
54 |
* - mb_stripos - Finds position of first occurrence of a string within another, case insensitive
|
55 |
* - mb_stristr - Finds first occurrence of a string within another, case insensitive
|
56 |
+
* - mb_strpos - Find position of first occurrence of string in a string
|
57 |
* - mb_strrchr - Finds the last occurrence of a character in a string within another
|
58 |
* - mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive
|
59 |
* - mb_strripos - Finds position of last occurrence of a string within another, case insensitive
|
60 |
+
* - mb_strrpos - Find position of last occurrence of a string in a string
|
61 |
* - mb_strstr - Finds first occurrence of a string within another
|
62 |
+
* - mb_substitute_character - Set/Get substitution character
|
63 |
* - mb_substr_count - Count the number of substring occurrences
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
*/
|
65 |
final class Mbstring
|
66 |
{
|
74 |
array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'),
|
75 |
);
|
76 |
|
77 |
+
public static function mb_convert_case($s, $mode, $encoding = null)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
{
|
79 |
+
if (!self::isIconvLoaded()) {
|
80 |
+
if (MB_CASE_UPPER == $mode) {
|
81 |
+
return \strtoupper($s);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
+
if (MB_CASE_LOWER == $mode) {
|
84 |
+
return \strtolower($s);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
|
|
|
|
|
|
|
|
|
|
86 |
return $s;
|
87 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
$s = (string) $s;
|
89 |
if ('' === $s) {
|
90 |
return '';
|
91 |
}
|
|
|
92 |
$encoding = self::getEncoding($encoding);
|
|
|
93 |
if ('UTF-8' === $encoding) {
|
94 |
$encoding = null;
|
95 |
if (!preg_match('//u', $s)) {
|
98 |
} else {
|
99 |
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
100 |
}
|
|
|
101 |
if (MB_CASE_TITLE == $mode) {
|
102 |
static $titleRegexp = null;
|
103 |
if (null === $titleRegexp) {
|
115 |
if (self::MB_CASE_FOLD === $mode) {
|
116 |
$s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
|
117 |
}
|
|
|
118 |
static $lower = null;
|
119 |
if (null === $lower) {
|
120 |
$lower = self::getData('lowerCase');
|
121 |
}
|
122 |
$map = $lower;
|
123 |
}
|
|
|
124 |
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
|
|
|
125 |
$i = 0;
|
126 |
$len = \strlen($s);
|
|
|
127 |
while ($i < $len) {
|
128 |
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
|
129 |
$uchr = substr($s, $i, $ulen);
|
130 |
$i += $ulen;
|
|
|
131 |
if (isset($map[$uchr])) {
|
132 |
$uchr = $map[$uchr];
|
133 |
$nlen = \strlen($uchr);
|
|
|
134 |
if ($nlen == $ulen) {
|
135 |
$nlen = $i;
|
136 |
do {
|
144 |
}
|
145 |
}
|
146 |
}
|
|
|
147 |
if (null === $encoding) {
|
148 |
return $s;
|
149 |
}
|
|
|
150 |
return iconv('UTF-8', $encoding.'//IGNORE', $s);
|
151 |
}
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
public static function mb_strlen($s, $encoding = null)
|
154 |
{
|
155 |
$encoding = self::getEncoding($encoding);
|
156 |
+
if (!self::isMultibyte($encoding)) {
|
157 |
return \strlen($s);
|
158 |
}
|
|
|
159 |
return @iconv_strlen($s, $encoding);
|
160 |
}
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
public static function mb_strtolower($s, $encoding = null)
|
163 |
{
|
164 |
return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
|
169 |
return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
|
170 |
}
|
171 |
|
172 |
+
public static function mb_strwidth($s, $encoding = null)
|
173 |
{
|
174 |
+
$encoding = self::getEncoding($encoding);
|
175 |
+
if (!self::isIconvLoaded()) {
|
176 |
+
return \strlen($s);
|
177 |
}
|
178 |
+
if ('UTF-8' !== $encoding) {
|
179 |
+
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
180 |
+
}
|
181 |
+
$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);
|
182 |
+
return ($wide << 1) + iconv_strlen($s, 'UTF-8');
|
183 |
}
|
184 |
|
185 |
public static function mb_substr($s, $start, $length = null, $encoding = null)
|
186 |
{
|
187 |
$encoding = self::getEncoding($encoding);
|
188 |
+
if (!self::isMultibyte($encoding)) {
|
189 |
+
return (string) \substr($s, $start, null === $length ? 2147483647 : $length);
|
190 |
}
|
|
|
191 |
if ($start < 0) {
|
192 |
$start = iconv_strlen($s, $encoding) + $start;
|
193 |
if ($start < 0) {
|
194 |
$start = 0;
|
195 |
}
|
196 |
}
|
|
|
197 |
if (null === $length) {
|
198 |
$length = 2147483647;
|
199 |
} elseif ($length < 0) {
|
202 |
return '';
|
203 |
}
|
204 |
}
|
|
|
205 |
return (string) iconv_substr($s, $start, $length, $encoding);
|
206 |
}
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
private static function getData($file)
|
209 |
{
|
210 |
if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
|
211 |
return require $file;
|
212 |
}
|
|
|
213 |
return false;
|
214 |
}
|
215 |
|
218 |
if (null === $encoding) {
|
219 |
return self::$internalEncoding;
|
220 |
}
|
|
|
221 |
if ('UTF-8' === $encoding) {
|
222 |
return 'UTF-8';
|
223 |
}
|
|
|
224 |
$encoding = strtoupper($encoding);
|
|
|
225 |
if ('8BIT' === $encoding || 'BINARY' === $encoding) {
|
226 |
return 'CP850';
|
227 |
}
|
|
|
228 |
if ('UTF8' === $encoding) {
|
229 |
return 'UTF-8';
|
230 |
}
|
|
|
231 |
return $encoding;
|
232 |
}
|
233 |
+
|
234 |
+
private static function isIconvLoaded()
|
235 |
+
{
|
236 |
+
return extension_loaded('iconv');
|
237 |
+
}
|
238 |
+
|
239 |
+
private static function isMultibyte($encoding)
|
240 |
+
{
|
241 |
+
return self::isIconvLoaded() && !('CP850' === $encoding || 'ASCII' === $encoding);
|
242 |
+
}
|
243 |
}
|
vendors/symfony/polyfill-mbstring/bootstrap.php
CHANGED
@@ -1,135 +1,39 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
* This
|
5 |
-
*
|
6 |
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
use GeminiLabs\Symfony\Polyfill\Mbstring as p;
|
13 |
|
14 |
-
if (!function_exists('mb_convert_encoding')) {
|
15 |
-
function mb_convert_encoding($s, $to, $from = null) { return p\Mbstring::mb_convert_encoding($s, $to, $from); }
|
16 |
-
}
|
17 |
-
if (!function_exists('mb_decode_mimeheader')) {
|
18 |
-
function mb_decode_mimeheader($s) { return p\Mbstring::mb_decode_mimeheader($s); }
|
19 |
-
}
|
20 |
-
if (!function_exists('mb_encode_mimeheader')) {
|
21 |
-
function mb_encode_mimeheader($s, $charset = null, $transferEnc = null, $lf = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($s, $charset, $transferEnc, $lf, $indent); }
|
22 |
-
}
|
23 |
-
if (!function_exists('mb_decode_numericentity')) {
|
24 |
-
function mb_decode_numericentity($s, $convmap, $enc = null) { return p\Mbstring::mb_decode_numericentity($s, $convmap, $enc); }
|
25 |
-
}
|
26 |
-
if (!function_exists('mb_encode_numericentity')) {
|
27 |
-
function mb_encode_numericentity($s, $convmap, $enc = null, $is_hex = false) { return p\Mbstring::mb_encode_numericentity($s, $convmap, $enc, $is_hex); }
|
28 |
-
}
|
29 |
if (!function_exists('mb_convert_case')) {
|
30 |
function mb_convert_case($s, $mode, $enc = null) { return p\Mbstring::mb_convert_case($s, $mode, $enc); }
|
31 |
}
|
32 |
-
if (!function_exists('mb_internal_encoding')) {
|
33 |
-
function mb_internal_encoding($enc = null) { return p\Mbstring::mb_internal_encoding($enc); }
|
34 |
-
}
|
35 |
-
if (!function_exists('mb_language')) {
|
36 |
-
function mb_language($lang = null) { return p\Mbstring::mb_language($lang); }
|
37 |
-
}
|
38 |
-
if (!function_exists('mb_list_encodings')) {
|
39 |
-
function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
|
40 |
-
}
|
41 |
-
if (!function_exists('mb_encoding_aliases')) {
|
42 |
-
function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
|
43 |
-
}
|
44 |
-
if (!function_exists('mb_check_encoding')) {
|
45 |
-
function mb_check_encoding($var = null, $encoding = null) { return p\Mbstring::mb_check_encoding($var, $encoding); }
|
46 |
-
}
|
47 |
-
if (!function_exists('mb_detect_encoding')) {
|
48 |
-
function mb_detect_encoding($str, $encodingList = null, $strict = false) { return p\Mbstring::mb_detect_encoding($str, $encodingList, $strict); }
|
49 |
-
}
|
50 |
-
if (!function_exists('mb_detect_order')) {
|
51 |
-
function mb_detect_order($encodingList = null) { return p\Mbstring::mb_detect_order($encodingList); }
|
52 |
-
}
|
53 |
-
if (!function_exists('mb_parse_str')) {
|
54 |
-
function mb_parse_str($s, &$result = array()) { parse_str($s, $result); }
|
55 |
-
}
|
56 |
if (!function_exists('mb_strlen')) {
|
57 |
function mb_strlen($s, $enc = null) { return p\Mbstring::mb_strlen($s, $enc); }
|
58 |
}
|
59 |
-
if (!function_exists('mb_strpos')) {
|
60 |
-
function mb_strpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strpos($s, $needle, $offset, $enc); }
|
61 |
-
}
|
62 |
if (!function_exists('mb_strtolower')) {
|
63 |
function mb_strtolower($s, $enc = null) { return p\Mbstring::mb_strtolower($s, $enc); }
|
64 |
}
|
65 |
if (!function_exists('mb_strtoupper')) {
|
66 |
function mb_strtoupper($s, $enc = null) { return p\Mbstring::mb_strtoupper($s, $enc); }
|
67 |
}
|
68 |
-
if (!function_exists('mb_substitute_character')) {
|
69 |
-
function mb_substitute_character($char = null) { return p\Mbstring::mb_substitute_character($char); }
|
70 |
-
}
|
71 |
-
if (!function_exists('mb_substr')) {
|
72 |
-
function mb_substr($s, $start, $length = 2147483647, $enc = null) { return p\Mbstring::mb_substr($s, $start, $length, $enc); }
|
73 |
-
}
|
74 |
-
if (!function_exists('mb_stripos')) {
|
75 |
-
function mb_stripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_stripos($s, $needle, $offset, $enc); }
|
76 |
-
}
|
77 |
-
if (!function_exists('mb_stristr')) {
|
78 |
-
function mb_stristr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_stristr($s, $needle, $part, $enc); }
|
79 |
-
}
|
80 |
-
if (!function_exists('mb_strrchr')) {
|
81 |
-
function mb_strrchr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrchr($s, $needle, $part, $enc); }
|
82 |
-
}
|
83 |
-
if (!function_exists('mb_strrichr')) {
|
84 |
-
function mb_strrichr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrichr($s, $needle, $part, $enc); }
|
85 |
-
}
|
86 |
-
if (!function_exists('mb_strripos')) {
|
87 |
-
function mb_strripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strripos($s, $needle, $offset, $enc); }
|
88 |
-
}
|
89 |
-
if (!function_exists('mb_strrpos')) {
|
90 |
-
function mb_strrpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strrpos($s, $needle, $offset, $enc); }
|
91 |
-
}
|
92 |
-
if (!function_exists('mb_strstr')) {
|
93 |
-
function mb_strstr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strstr($s, $needle, $part, $enc); }
|
94 |
-
}
|
95 |
-
if (!function_exists('mb_get_info')) {
|
96 |
-
function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
|
97 |
-
}
|
98 |
-
if (!function_exists('mb_http_output')) {
|
99 |
-
function mb_http_output($enc = null) { return p\Mbstring::mb_http_output($enc); }
|
100 |
-
}
|
101 |
if (!function_exists('mb_strwidth')) {
|
102 |
function mb_strwidth($s, $enc = null) { return p\Mbstring::mb_strwidth($s, $enc); }
|
103 |
}
|
104 |
-
if (!function_exists('
|
105 |
-
function
|
106 |
-
}
|
107 |
-
if (!function_exists('mb_output_handler')) {
|
108 |
-
function mb_output_handler($contents, $status) { return p\Mbstring::mb_output_handler($contents, $status); }
|
109 |
-
}
|
110 |
-
if (!function_exists('mb_http_input')) {
|
111 |
-
function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
|
112 |
-
}
|
113 |
-
if (!function_exists('mb_convert_variables')) {
|
114 |
-
function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null) { return p\Mbstring::mb_convert_variables($toEncoding, $fromEncoding, $a, $b, $c, $d, $e, $f); }
|
115 |
-
}
|
116 |
-
if (!function_exists('mb_ord')) {
|
117 |
-
function mb_ord($s, $enc = null) { return p\Mbstring::mb_ord($s, $enc); }
|
118 |
-
}
|
119 |
-
if (!function_exists('mb_chr')) {
|
120 |
-
function mb_chr($code, $enc = null) { return p\Mbstring::mb_chr($code, $enc); }
|
121 |
-
}
|
122 |
-
if (!function_exists('mb_scrub')) {
|
123 |
-
function mb_scrub($s, $enc = null) { $enc = null === $enc ? mb_internal_encoding() : $enc; return mb_convert_encoding($s, $enc, $enc); }
|
124 |
-
}
|
125 |
-
if (!function_exists('mb_str_split')) {
|
126 |
-
function mb_str_split($string, $split_length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $split_length, $encoding); }
|
127 |
}
|
128 |
-
|
129 |
if (extension_loaded('mbstring')) {
|
130 |
return;
|
131 |
}
|
132 |
-
|
133 |
if (!defined('MB_CASE_UPPER')) {
|
134 |
define('MB_CASE_UPPER', 0);
|
135 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* This is an extract of the symfony/polyfill-mbstring package.
|
5 |
+
*
|
6 |
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
+
*
|
11 |
+
* @package symfony/polyfill-mbstring v1.18.1
|
12 |
*/
|
13 |
|
14 |
use GeminiLabs\Symfony\Polyfill\Mbstring as p;
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
if (!function_exists('mb_convert_case')) {
|
17 |
function mb_convert_case($s, $mode, $enc = null) { return p\Mbstring::mb_convert_case($s, $mode, $enc); }
|
18 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
if (!function_exists('mb_strlen')) {
|
20 |
function mb_strlen($s, $enc = null) { return p\Mbstring::mb_strlen($s, $enc); }
|
21 |
}
|
|
|
|
|
|
|
22 |
if (!function_exists('mb_strtolower')) {
|
23 |
function mb_strtolower($s, $enc = null) { return p\Mbstring::mb_strtolower($s, $enc); }
|
24 |
}
|
25 |
if (!function_exists('mb_strtoupper')) {
|
26 |
function mb_strtoupper($s, $enc = null) { return p\Mbstring::mb_strtoupper($s, $enc); }
|
27 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
if (!function_exists('mb_strwidth')) {
|
29 |
function mb_strwidth($s, $enc = null) { return p\Mbstring::mb_strwidth($s, $enc); }
|
30 |
}
|
31 |
+
if (!function_exists('mb_substr')) {
|
32 |
+
function mb_substr($s, $start, $length = 2147483647, $enc = null) { return p\Mbstring::mb_substr($s, $start, $length, $enc); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
|
|
34 |
if (extension_loaded('mbstring')) {
|
35 |
return;
|
36 |
}
|
|
|
37 |
if (!defined('MB_CASE_UPPER')) {
|
38 |
define('MB_CASE_UPPER', 0);
|
39 |
}
|