Skip to content

Commit

Permalink
fix PHP 8.0 ValueError: mb_convert_encoding(): Argument #3 ($from_enc…
Browse files Browse the repository at this point in the history
…oding) must specify at least one encoding
  • Loading branch information
ralfbecker authored and yunosh committed Jan 12, 2022
1 parent f64e368 commit ddd6e6e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/Horde/String.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ protected static function _convertCharset($input, $from, $to)

/* Try mbstring. */
if (Horde_Util::extensionExists('mbstring')) {
$out = @mb_convert_encoding($input, $to, self::_mbstringCharset($from));
if (!empty($out)) {
return $out;
}
try {
$out = @mb_convert_encoding($input, $to, self::_mbstringCharset($from));
if (!empty($out))
{
return $out;
}
}
catch (ValueError $e) {
// catch error thrown under PHP 8.0, if mbstring does not support the encoding
}
}

return $input;
Expand Down

0 comments on commit ddd6e6e

Please sign in to comment.