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 \
, but as far as i know the actual correct unicode should be \€
. Usually thats not a problem but the Droid Sans
Font does only render \€
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.
\
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.