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

+3


source to share


1 answer


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');

      

0


source







All Articles