I have a database which some of its table columns was in latin1_swedish_ci
, I used PDO connection without charset=utf8
and the data returned well with only using header('Content-Type: application/json; charset=UTF-8');
, then I have created some new table columns with utf8 encoding and when fetching the data it is returned like this ?????
, with some search I found that I have to use PDO connection with charset=utf8
, but adding the last one cause new tables work well, but old tables work wrong, I have used utf8_encoding
but nothing happened, what I have to do now, thanks in advance.
Asked
Active
Viewed 27 times
0

7AMOOOD
- 9
- 1
- 6
-
You should [convert all your db data/tables/columns to UTF-8](https://stackoverflow.com/questions/9407834/convert-latin1-characters-on-a-utf8-table-into-utf8) and then make sure you're using [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through). – M. Eriksson Apr 17 '21 at 23:41
-
I have converted all database tables to UTF8, also I have now utf8 in tables, columns , connection and header content, now my problem is I have a data in latin and utf8 in my database and want to return it correctly, but latin data returned wrong الدمام – 7AMOOOD Apr 18 '21 at 19:04
-
need any solution except using that CONVERT(CAST(t1.`name` as BINARY) USING utf8) as name – 7AMOOOD Apr 18 '21 at 19:06