Often when outputting strings from a database onto a webpage, special characters get displayed as some other weird characters (in my example, an em-dash gets tu
Mojibake - This is the classic case of
SET NAMES latin1
(or set_charset('latin1')
or ...), probably by default. (It should have been utf8
.)CHARACTER SET latin1
. (Or possibly it was inherited from the table/database.) (It should have been utf8
.)in your html view page use
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
and if you are inserting some other language character in place of english than make that column utf8-general-ci
You can try this.Use following php inbuilt function to avoid those characters on given string. In your case, data from database.
html_entity_decode($given_string,ENT_QUOTES, "ISO-8859-1");
On top of your page in header tag use the below code:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">