|
@@ 1944-1951 (lines=8) @@
|
| 1941 |
|
* will be returned, unless either the <b>ENT_IGNORE</b> or |
| 1942 |
|
* <b>ENT_SUBSTITUTE</b> flags are set. |
| 1943 |
|
*/ |
| 1944 |
|
public static function htmlspecialchars(string $str, int $flags = ENT_COMPAT, string $encoding = 'UTF-8', bool $double_encode = true): string |
| 1945 |
|
{ |
| 1946 |
|
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
| 1947 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 1948 |
|
} |
| 1949 |
|
|
| 1950 |
|
return \htmlspecialchars($str, $flags, $encoding, $double_encode); |
| 1951 |
|
} |
| 1952 |
|
|
| 1953 |
|
/** |
| 1954 |
|
* Checks whether iconv is available on the server. |
|
@@ 5574-5588 (lines=15) @@
|
| 5571 |
|
* |
| 5572 |
|
* @return int |
| 5573 |
|
*/ |
| 5574 |
|
public static function strwidth(string $str, string $encoding = 'UTF-8', bool $cleanUtf8 = false): int |
| 5575 |
|
{ |
| 5576 |
|
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
| 5577 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 5578 |
|
} |
| 5579 |
|
|
| 5580 |
|
if ($cleanUtf8 === true) { |
| 5581 |
|
// iconv and mbstring are not tolerant to invalid encoding |
| 5582 |
|
// further, their behaviour is inconsistent with that of PHP's substr |
| 5583 |
|
$str = self::clean($str); |
| 5584 |
|
} |
| 5585 |
|
|
| 5586 |
|
// fallback to "mb_"-function via polyfill |
| 5587 |
|
return \mb_strwidth($str, $encoding); |
| 5588 |
|
} |
| 5589 |
|
|
| 5590 |
|
/** |
| 5591 |
|
* Get part of a string. |