Gabriël
Gabriël

Reputation: 1315

How can I convert HTML characters to their equivalents on the iPhone?

I want to convert:

<?xml version="1.0"?>
  <Company>
    <CompanyId>5</CompanyId>
    <Name>Acme Inc.</Name>
  </Company>

To:

<?xml version="1.0"?>
  <Company>
    <CompanyId>5</CompanyId>
    <Name>Acme Inc.</Name>
  </Company>

on a iPhone. But I can't find any standard functions available on the iPhone, nor could I find any mature (open source) libraries.

Upvotes: 0

Views: 555

Answers (3)

SnowboardBruin
SnowboardBruin

Reputation: 3685

Grab MWFeedParser from GitHub, one of the files will convert everything for you

https://github.com/mwaterfall/MWFeedParser

look at this functions

  • (NSString *)stringByDecodingHTMLEntities;
  • (NSString *)stringByEncodingHTMLEntities;

...this should at least lead you in the right direction

Upvotes: 0

Aarjav
Aarjav

Reputation:

CFXMLCreateStringByUnescapingEntities works OK on the simulator but not on the device.

Upvotes: 0

Hank Gay
Hank Gay

Reputation: 71979

Will CFXMLCreateStringByUnescapingEntities work for you?

Upvotes: 1

Related Questions