我有用户输入并使用 htmlentities() 来转换所有实体。但是,似乎有一些错误。当我输入
ääää öööö üüüü ääää
我明白了
ääää öööö üüüü ääää
看起来像这样
ääää öööö üüüü ääää
我究竟做错了什么?代码真的只有这样:
$post=htmlentities($post);
编辑 1
这是我用于格式化目的的更多代码(其中有一些有用的功能):
    //Secure with htmlentities (mysql_real_escape_string() comes later)
    $post=htmlentities($post);
    //Strip obsolete white spaces
    $post = preg_replace("/ +/", " ", $post);
    //Detect links
    $pattern_url='~(?>[a-z+]{2,}://|www\.)(?:[a-z0-9]+(?:\.[a-z0-9]+)?@)?(?:(?:[a-z](?:[a-z0-9]|(?<!-)-)*[a-z0-9])(?:\.[a-z](?:[a-z0-9]|(?<!-)-)*[a-z0-9])+|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?:/[^\\/:?*"<>|\n]*[a-z0-9])*/?(?:\?[a-z0-9_.%]+(?:=[a-z0-9_.%:/+-]*)?(?:&[a-z0-9_.%]+(?:=[a-z0-9_.%:/+-]*)?)*)?(?:#[a-z0-9_%.]+)?~i';
    preg_match_all($pattern_url, $post, $matches); 
    for ($i=0; $i < count($matches[0]); $i++)
    {
        if(substr($matches[0][$i],0,4)=='www.')
        $post = str_replace($matches[0][$i],'http://'.$matches[0][$i],$post);
    }
    $post = preg_replace($pattern_url,'<a target="_blank" href="\\0">\\0</a>',$post);
    //Keep line breaks (more than one will be stripped above)
    $post=nl2br($post);
    //Remove more than one linebreak
    $post=preg_replace("/(<br\s*\/?>\s*)+/", "<br/>", $post);
    //Secure with mysql_real_escape_string()
    $post=mysql_real_escape_string($post);