What alternative methods, besides htmlentities(), can be used to convert German umlauts to HTML entities in PHP for better compatibility and display on different platforms?

When displaying German umlauts in HTML, it is important to convert them to HTML entities to ensure proper compatibility and display on different platforms. Apart from using htmlentities(), another method to achieve this is by using the htmlspecialchars() function in PHP. This function converts special characters to HTML entities, including German umlauts, ensuring they are displayed correctly in HTML.

$text = "Möglichkeiten für HTML-Umwandlung";
$html_safe_text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
echo $html_safe_text;