Unicode character rendered as ascii encoded on client side
I am trying to show emoji using its unicode value (π). But I am getting an escaped string like \u00f0\u0178\u02dc\u20ac
which is decoded to Γ°ΕΈΛβ¬
.
I am using Mysql server and PHP 5.4 in my project. In mysql, it is stored as Γ°ΕΈΛβ¬
. Is there a way to unescape this and return the actual unicode from the PHP server
I tried
iconv('ASCII//TRANSLIT', 'UTF-8', 'Γ°ΕΈΛβ¬');
, mb_convert_encoding($var, "US-ASCII", "UTF-8")
and utf8_encode (). does not work.
thank
source to share
Without knowing the structure of your database (make sure you use utf8
as the character set for your table!), I think the problem might only be on the display side. Try running the PHP script by sending a header to the browser that lets it know that you are going to display UTF8 characters and not western encoding ( ISO-8859-1
).
header('Content-type text/html; charset=UTF-8');
source to share