Reputation: 4944
I have this words (and more 40 in same case) in customer databases:
Aclimação
Aclimação
I need convert both to UTF-8 and save in MySQL database: Aclimação.
How I do that with PHP?
[EDIT]
Observation:
I need do that because, when user find specific 'district', its impossible convert in two formats, for example:
Aclimaç&aatilde;o (correct)
Aclimação (incorrect: utf8 + html number encode)
Aclimação (incorrect: iso + html number encode)
I need just 1 type of encode, in my case: ISO-8859-1.
Upvotes: 1
Views: 292
Reputation: 4944
How did the following solution, converted all data from the database, using the function:
mb_convert_encoding (data, 'UTF-8', 'HTML-ENTITIES');
When I read the record, do the following:
utf8_decode (data)
When I look for some record, based on the selection of sites (), I do the following:
utf8_encode (data)
And so far, worked perfectly.
Upvotes: 1
Reputation: 53462
I don't think for example ã exists in ISO-8859-1, so you do actually need UTF-8 for it. It is not correct to have it as &aatilde;
, that is HTML way of representing it.
Upvotes: 1
Reputation:
Get the values and insert them to the database after applying html_entity_decode() to the string.
(The second string you provided looks like it has a malformed HTML entity, is that right?)
Upvotes: 1