Reputation: 14161
I'm losing accented characters.
From PHP I download an xml file which uses UTF8, while my PHP script uses Latin1. I can't manage to convert the UTF8 into Latin1.
I've tried this:
$meta=mb_convert_encoding($meta,'CP1252','UTF-8');
and
$meta=mb_convert_encoding($meta,'UTF-8');
$meta=mb_convert_encoding($meta,'CP1252','UTF-8');
But either way the accented characters are broken and turned into 2 characters.
Input:
<title>First book of zoölogy</title>
Output:
<title>First book of zoo?logy</title>
I figured it out myself, see my answer below. Thank you everyone for your help!
Upvotes: 0
Views: 1476
Reputation: 14161
This fixed it:
$meta=iconv('UTF-8','CP1252//TRANSLIT',$meta);
I didn't know about iconv before, I thought there was only mb_strings to work with, but iconv works very well.
Upvotes: 1
Reputation: 3246
Maybe default charset of your MySQL server is UTF-8. Try this:
Insert the following query after your MySQL connection details:
mysql_query("SET NAMES latin1");
Upvotes: 0
Reputation: 73
Change the collation of the tables do Utf8_general_ci and before conections to the database use:
mysql_set_charset("utf8");
I think this can solve your problem.
Upvotes: 1