I've just spent the last 3 hours tracking down a display problem on one of my pages. The text was a garbled mess. The problem turned out to be the use of utf8_encode
on an existing utf8 string. As noted in the docs it can only convert ISO-8859-1. Why does it have such a misleading name? /rant.
What is the proper, less error prone, way of detecting and converting encodings in PHP?
Either
mb_convert_encoding
oriconv
, depending on what's installed on your server. (iconv is enabled by default, however, mbstring is not.)