Why are HTML objects displayed on the iPhone / iPhone simulator even after deleting them using PHP?

I am sending a JSON encoded request response from an iPhone. Few values ​​have some HTML entities. I tried to use stripslashes()and html_entity_decode()on such values. In the browser, I can get the correct JSON response, i.e. Without these HTML entities, but when the same response is displayed on the iPhone or iPhone simulator, the HTML objects are displayed again.

How do I solve this problem? Can someone help?

If you want, I can provide you the necessary code.

Thank.

+4
source share
3 answers

in PHP

<?php
header('Content-Type: application/json');
echo json_encode(array('test' => html_entity_decode("Hello &#8211; World", ENT_COMPAT, 'UTF-8')));

:

{"test":"Hello \u2013 World"}

JS:

var o = jQuery.parseJSON('{"test":"Hello \u2013 World"}');
alert( o.test );

:

Hello – World
+2

https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m & Objective-C

NSString, "GTMNSString + HTML", Google. : gist.github.com/takuma104/ntlniph/blob/master/gtm/Foundation/GTMNSString+HTML.h : gist.github.com/takuma104/ntlniph/blob/master/gtm/Foundation/GTMNSString + HTML.m

+1

All Articles