Reputation: 411
My actual string is
Mom said, "I love this one." Jake said, "I don’t get it."
But instead it
In my database in one column the value is saving like that i cant change
Mom said, “I love this one.†Jake said, “I don’t get it.â€
I am fetching that from query and do json_encode then it display the output like this in json string
Mom said, \u00e2\u20ac\u0153I love this one.\u00e2\u20ac\u009d\n\nJake said, \u00e2\u20ac\u0153I don\u00e2\u20ac\u2122t get it.\u00e2\u20ac\u009d\n
So please tell me how to decode this unicode into double quotes.
thanks in advance
Upvotes: 1
Views: 5485
Reputation: 2255
The data that you already have probably needs to be passed through utf8_decode()
(not utf8_encode()
).
To ensure smooth sailing in the future, you should make sure your whole pipe is UTF-8. This is non-trivial, sadly. Off the top of my head, places that need to be checked:
AddDefaultCharset UTF-8
php_value default_charset "UTF-8"
header('Content-Type: text/html; charset=UTF-8');
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
mysql_set_charset('utf8');
utf8
and collation utf8_general_ci
utf8
and collation utf8_general_ci
And if you need to output values that may contain unwanted HTML or XML, use htmlentities($var, ENT_COMPAT, 'UTF-8');
instead of simply htmlentities($var);
Also, use the mb_*
functions where possible, such as mb_strlen()
and mb_substr()
.
Upvotes: 3
Reputation: 4146
Change your table collation to latin1_swedish_ci
With special char you can also do something like this
for displaying the data from mysql
$str=html_entity_decode(stripslashes($rows[4]));
for inserting the data with special characters into mysql
$var_name=htmlentities(mysql_real_escape_string($detail));
Upvotes: -1