I am trying to post comment using 'Percent Encoding', everything seems to work however, when the php file save the value to a JSON list the encoding is changed to "\u2764\ufe0f".
Why is this happening? Should not JSON index the data as a string?
Swift:
let emo = "%E2%9D%A4%EF%B8%8F"
emo.stringByRemovingPercentEncoding // ♥
Alamofire.request(
.POST,
"https://example.com/test.php?MyComment=\(emo)", parameters: ["":""])
PHP:
$results = array ( array(
"MyComment" => $MyComment
));
$inp = file_get_contents('Test.json');
$arr = json_decode($inp);
$results = array_merge($results, $arr);
$fp_login = fopen('Test.json', w);
fwrite($fp_login, json_encode($results));
fclose($fp_login);
echo $results // [{"MyComment":"\u2764\ufe0f"}]
should be saved as [{"MyComment":"%E2%9D%A4%EF%B8%8F"}]