Twifty
Twifty

Reputation: 3378

php correctly convert between encodings

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?

Upvotes: 1

Views: 61

Answers (1)

pilsetnieks
pilsetnieks

Reputation: 10420

Either mb_convert_encoding or iconv, depending on what's installed on your server. (iconv is enabled by default, however, mbstring is not.)

Upvotes: 2

Related Questions