How can one ensure that Umlaut characters are preserved when using htmlspecialchars() in PHP?

When using htmlspecialchars() in PHP to escape special characters in a string, umlaut characters may not be preserved and can be converted to their HTML entity equivalents. To ensure that umlaut characters are preserved, you can set the fourth parameter of htmlspecialchars() to false, which will prevent the conversion of umlaut characters to HTML entities.

$string = "Möglichkeiten & Lösungen";
$escaped_string = htmlspecialchars($string, ENT_QUOTES, 'UTF-8', false);
echo $escaped_string;