I am loading data in an android app from a php service. In php i use json_encode to convert my data. Now i have a string with a €
character in it. json_encode
converts this to \u0080
, but as far as i know the actual correct unicode should be \u20AC
. Usually thats not a problem but the Droid Sans
Font does only render \u20AC
as the euro symbol.
My question: Is there a way to make the €
character convert correctly (i dont care if thats in Java
or in PHP
, although i would prefer a php solution) without using any string replaces or regex etc.. replacing seems ugly and there might be more symbols that dont get converted properly that i dont know of yet.
\u0080
means that the input character was \x80
which is the Euro sign in Windows-1252. So I assume your string is encoded in this charset, then you should convert it to UTF-8 because json_encode
only works with UTF-8 input:
$string = iconv('Windows-1252', 'UTF-8', $string);