Handle malformed latin1 encoding
Posted: Wed Sep 01, 2010 11:25 am
Hi all,
In short:
I've got a latin1 encoded MySQL table with utf8 characters in it. How can I properly escape the utf8 characters in PHP?
In detail:
I've got a database table with the latin1 character set. I can't convert it to utf8 because that'll seriously cut down the allowed size of the row - and I need it as large as possible. I've imported french characters, which in the latin1 encoding get stored as a ?. When I take that value out of the DB & try to display it with PHP, htmlspecialcharacters() craps itself & breaks output. Is there a way I can either:
In short:
I've got a latin1 encoded MySQL table with utf8 characters in it. How can I properly escape the utf8 characters in PHP?
In detail:
I've got a database table with the latin1 character set. I can't convert it to utf8 because that'll seriously cut down the allowed size of the row - and I need it as large as possible. I've imported french characters, which in the latin1 encoding get stored as a ?. When I take that value out of the DB & try to display it with PHP, htmlspecialcharacters() craps itself & breaks output. Is there a way I can either:
- Properly escape the string when reading from the tables, or
- Properly convert utf8 characters (such as é -> e) when being imported