PHP解码急

I've got string:

$str = "Końcówki";

My target string is:

$str = "Końcówki";

echo html_entity_decode($d); // Końc�wki

echo utf8_encode(html_entity_decode($d)); // KoÅcówki

How to decode it without crashing other special chars?

The character needs to be decoded into some charset. The string already contains a character which is encoded in a specialized charset. You need to tell html_entities_decode to decode to that same charset. At the moment there's a mismatch between the two.

html_entity_decode($str, ENT_COMPAT, 'your charset here')