April 29, 2012
PHP UTF-8 Encoding in HTML Input Box
Question by Wasim
Here what is in database
Seilpendel für Tragsysteme
now i am loading it into textbox via AJAX but what loads into textbox is
Seilpendel f�r Tragsysteme
but i want correct string Seilpendel für Tragsysteme
into inputbox
i have tried
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
but not its working
Answer by mcdado
Make sure the db is encoded in UTF8, or use utf8_encode() or utf8_decode() when loading data from db or when writing back.
Answer by Starx
The correct way solving this problem is to configure database to use UTF8 as their character encoding in and out.
RUN The following query after connecting to the database, one time and everything should start working.
SET NAMES 'utf8';