|
@@ 2315-2322 (lines=8) @@
|
| 2312 |
|
* will be returned, unless either the <b>ENT_IGNORE</b> or |
| 2313 |
|
* <b>ENT_SUBSTITUTE</b> flags are set. |
| 2314 |
|
*/ |
| 2315 |
|
public static function htmlspecialchars(string $str, int $flags = ENT_COMPAT, string $encoding = 'UTF-8', bool $double_encode = true): string |
| 2316 |
|
{ |
| 2317 |
|
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
| 2318 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 2319 |
|
} |
| 2320 |
|
|
| 2321 |
|
return \htmlspecialchars($str, $flags, $encoding, $double_encode); |
| 2322 |
|
} |
| 2323 |
|
|
| 2324 |
|
/** |
| 2325 |
|
* Checks whether iconv is available on the server. |
|
@@ 6568-6582 (lines=15) @@
|
| 6565 |
|
* |
| 6566 |
|
* @return int |
| 6567 |
|
*/ |
| 6568 |
|
public static function strwidth(string $str, string $encoding = 'UTF-8', bool $cleanUtf8 = false): int |
| 6569 |
|
{ |
| 6570 |
|
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
| 6571 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 6572 |
|
} |
| 6573 |
|
|
| 6574 |
|
if ($cleanUtf8 === true) { |
| 6575 |
|
// iconv and mbstring are not tolerant to invalid encoding |
| 6576 |
|
// further, their behaviour is inconsistent with that of PHP's substr |
| 6577 |
|
$str = self::clean($str); |
| 6578 |
|
} |
| 6579 |
|
|
| 6580 |
|
// fallback to "mb_"-function via polyfill |
| 6581 |
|
return \mb_strwidth($str, $encoding); |
| 6582 |
|
} |
| 6583 |
|
|
| 6584 |
|
/** |
| 6585 |
|
* Get part of a string. |