fix: Вместо подавления ошибки в mb_string-функциях ловим выпадающий эксепшен

This commit is contained in:
u_mulder 2023-03-06 17:48:54 +03:00
parent a306ea53af
commit 229e2e8a72

View File

@ -599,11 +599,18 @@ class Message
} }
$converted = null; $converted = null;
if (!$converted && function_exists('mb_convert_encoding') && @mb_check_encoding($text, $from)) { if (!$converted && function_exists('mb_convert_encoding')) {
$converted = @mb_convert_encoding($text, $to, $from); try {
if (mb_check_encoding($text, $from)) {
$converted = mb_convert_encoding($text, $to, $from);
}
} catch (\ValueError $e) {
// noop
}
} }
if (!$converted && function_exists('iconv')) { if (!$converted && function_exists('iconv')) {
// Для `iconv` @ пока работает
$converted = @iconv($from, $to . self::$charsetFlag, $text); $converted = @iconv($from, $to . self::$charsetFlag, $text);
} }