Htmlentities zaten kodlanmış öğeleri kodlama değil

5 Cevap php

Ben şöyle bir dize var:

Bürstner    

Bunun üzerine htmlentitiesi () kullandığınızda, ben false double encode param ayarlamak, ama yine   içine   yeniden kodlama biter

Ben kodlamak için bu kullanıyorum:

$out = htmlentities($string,ENT_NOQUOTES, 0);

Ben bir şekilde bu işleri nasıl yanlış anlama muyum? Istenen çıkış Umlaut u kodlayan, ancak tek başına mevcut nbsp varlıkları bırakmak için (bu sadece bir örnek, birçok kişiler zaten very long belgede vardır).

** EDIT **

Bu belirsiz, özgün dize görünüyor beri:

Bürstner   

İSTENİLEN ÇIKIŞ:

Bürstner   

Mevcut kişiler yalnız bırakılmalıdır.

5 Cevap

, htmlentities is the charset parametresinin üçüncü parametre Dördüncü parametre double_encode parametredir. Yani bu deneyin:

$out = htmlentities($string, ENT_NOQUOTES, ini_get('default_charset'), false);

Üçüncü argüman charset olduğunu; false, üçüncü değil, dördüncü ayarlamanız gerekir.

Htmlentities 3. parametre charset olduğunu .. false 4 ayarlamak gerekir

string htmlentities ( string $string [, int $quote_style = ENT_COMPAT [, string $charset [, bool $double_encode = true ]]] )

http://www.php.net/manual/en/function.htmlentities.php

Bu gözden kaçan geliyor bana the third parameter to htmlentities():

dize htmlentities (string $ dizge [, int $ öncelem_türü = ENT_COMPAT [, string $ charset [, bool $ çifte_kodlama = true]]])

denemek

$out = htmlentities($string, ENT_NOQUOTES, <whatever encoding you're using>, false);

Bu fonksiyon bir göz

The link for it http://php.net/manual/de/function.htmlspecialchars.php

<?php
function special_formatting($input) {
    $output = htmlspecialchars($input, ENT_QUOTES);
    $output = str_replace(array('  ', "\n"), array('&nbsp;&nbsp;', '<br>'), $output);
    return str_replace('&nbsp; ', '&nbsp;&nbsp;', $output);
}
?>