Codice PHP:
$str = "\xFC"; // ho scritto ü dal mio editor impostando UTF-8, ma l'esadecimale FC indica il medesimo carattere ma con codifica ISO-8859-1
// Outputs an empty string
var_dump(htmlentities($str, ENT_QUOTES | ENT_HTML401, "UTF-8"));
$correct = "\xC3\xBC";
var_dump(str_replace('&', '&', htmlentities($correct, ENT_QUOTES | ENT_HTML401, "UTF-8"))); //Output sorgente ü, se visualizzato con mime type text/html e l'agente utente lo supporta si vedrà ü
Significa che il tuo browser sta usando ISO-8859-1 quando copi (da una pagina HTML ISO-8859-1), mentre conserva questo charset anche quando incolli in una pagina UTF-8.