Thursday, 31 August 2017

html - PHP - bad encoded turkish characters in MySQL database

Answer


I am working on a turkish website, which has stored many malformed turkish characters in a MySQL database, like:



 - ş as þ
- ı as ý
- ğ as ð
- Ý as İ



i can not change the data in the database, because the database are updated daily and the new data will contain the malformed characters again. So my idea was to change the data in PHP instead of changing the data in the database. I have tried some steps:



Turkish characters are not displayed correctly



Fix Turkish Charset Issue Html / PHP (iconv?)



PHP Turkish Language displaying issue



PHP MYSQL encoding issue ( Turkish Characters )




I am using the PHP-MySQLi-Database-Class available on GitHub with utf8 as charset.



I have even tried to replace the malformed characters with str_replace, like:



$newString = str_replace ( chr ( 253 ), "ı", $newString );


My question is, how can i solve the issue without changing the characters in the database? Are there any best practices? Is it a good option just to replace the characters?



EDIT:

solved it by using




No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...